Not sure about your actual kml file but I know that I had to add the mime type definition to my server that supplied the kml file in order to have it recognized property for my app. This is described on the following page:
http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server Jerald From: [email protected] [mailto:[email protected]] On Behalf Of Dylan Parry Sent: Thursday, June 30, 2011 8:27 AM To: [email protected] Subject: EXT :[OpenLayers-Users] Using KML and retrieving features Hi, I’ve added a KML layer to a map, and it’s a fairly big layer (~10MB) but the site I’m creating is to be ran locally so that shouldn’t matter too much. The first problem I’ve got is that the KML doesn’t actually seem to display. The code I’ve got adding it as as follows: data = new OpenLayers.Layer.Vector("KML", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "/data/data.xml", format: new OpenLayers.Format.KML({ extractAttributes: true, extractStyles: true }) }) }); _map.addLayer(data); I had to rename the file to .xml as the local server didn’t like the .kml extension, so refused to serve the file. Now the file is definitely being requested as Chrome inspector shows that it’s been downloaded successfully and I get no JavaScript errors, but I’m not getting anything shown in the map display. Could this be because the KML file is too big? Or am I doing something wrong? I actually only want to display the file to check that it’s working properly, but eventually I’ll be hiding the layer anyway, so if it’s not displayable but still usable for querying, then that’s okay! The second question I have is about interrogating the KML layer. What I want to do is be able to double-click on the map, extract the coordinates of the clicked location, and then retrieve the attributes of any feature within the KML layer that was at the clicked location. I’m able to do the double-click handler, and extract the coordinates simply enough, but how do I then go about retrieving the features within the KML file for the selected coordinates? How then would I extract the attributes for that feature? Thanks in advance, -- Dylan Parry
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
