Hi,<br><br>I have a KML layer which I want to be able to click and see a pop up. I am following the following examples, but it's not working for me.<br><br><a href="http://openlayers.org/dev/examples/select-feature.html">http://openlayers.org/dev/examples/select-feature.html</a><br>
<a href="http://openlayers.org/dev/examples/select-feature-openpopup.html">http://openlayers.org/dev/examples/select-feature-openpopup.html</a><br><br>My map is projected. The init code is:<br><br>var options = {<br> projection: new OpenLayers.Projection("EPSG:900913"),<br>
displayProjection: new OpenLayers.Projection("EPSG:4326"),<br> units: "m",<br> maxResolution: 156543.0339,<br> maxExtent: new OpenLayers.Bounds(-20037508, -20037508,<br> 20037508, 20037508.34),<br>
restrictedExtent: new OpenLayers.Bounds(-102731.36592167988,-3815736.451414842,3869548.1192908203,-1311047.9090148422)<br> };<br> map = new OpenLayers.Map('map', options);<br><br>My KML is therefore also projected. The code:<br>
<br>kmlLayer = new OpenLayers.Layer.GML("KML", kmlFeedUrl,<br> {<br> projection: new OpenLayers.Projection("EPSG:4326"),<br> format: OpenLayers.Format.KML,<br> formatOptions: {<br> extractStyles: true,<br>
extractAttributes: true<br> }<br> });<br><br> map.addLayer(kmlLayer);<br><br>This is all working so far, and I'm pretty happy about it. Thanks goes out to Chris and the community.<br><br>My KML consist of points.<br>
<br><?xml version="1.0" encoding="UTF-8"?><br><kml xmlns="<a href="http://earth.google.com/kml/2.1">http://earth.google.com/kml/2.1</a>"><br> <Document><br> <Style id="marker"><br>
<IconStyle><br> <Icon><br> <href><a href="http://localhost:3000/openlayers/img/marker-green.png">http://localhost:3000/openlayers/img/marker-green.png</a></href><br> </Icon><br>
</IconStyle><br> </Style><br> <Placemark id="13856"><br> <name>place name</name><br> <description>NULL::character varying</description><br> <styleUrl>#marker</styleUrl><br>
<Point><br> <altitudeMode>relativeToGround</altitudeMode><br> <coordinates>23.29555556,-17.98611111</coordinates><br> </Point><br> </Placemark><br> <Placemark id="13852"><br>
<name>place name 2</name><br> <description>NULL::character varying</description><br> <styleUrl>#marker</styleUrl><br> <Point><br> <altitudeMode>relativeToGround</altitudeMode><br>
<coordinates>24.56638889,-17.54027778</coordinates><br> </Point><br> </Placemark><br> </Document><br></kml><br><br>I would like the user to be able to click on these points, and see a popup window consisting of name and description. After this KML layer is added, I add a select control as suggested from Vector file popup examples.<br>
<br>selectControl = new OpenLayers.Control.SelectFeature( kmlLayer,<br> {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});<br><br>I also copied over onFeatureSelect and onFeatureUnselect.<br>
<br>When I click on a marker, nothing happens. Do I need to project SelectFeature? Does SelectFeature work with Points from a KML file?<br><br>Sorry for the long post! Any help is much appreciated.<br><br>Xin<br><br>