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&#39;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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; projection: new OpenLayers.Projection(&quot;EPSG:900913&quot;),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; displayProjection: new OpenLayers.Projection(&quot;EPSG:4326&quot;),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; units: &quot;m&quot;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxResolution: 156543.0339,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxExtent: new OpenLayers.Bounds(-20037508, -20037508,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20037508, 20037508.34),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; restrictedExtent:&nbsp; new OpenLayers.Bounds(-102731.36592167988,-3815736.451414842,3869548.1192908203,-1311047.9090148422)<br>&nbsp;&nbsp;&nbsp; };<br>&nbsp;&nbsp;&nbsp; map = new OpenLayers.Map(&#39;map&#39;, options);<br><br>My KML is therefore also projected. The code:<br>
<br>kmlLayer = new OpenLayers.Layer.GML(&quot;KML&quot;, kmlFeedUrl,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; projection: new OpenLayers.Projection(&quot;EPSG:4326&quot;),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; format: OpenLayers.Format.KML,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; formatOptions: {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extractStyles: true,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extractAttributes: true<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br><br>&nbsp;&nbsp; map.addLayer(kmlLayer);<br><br>This is all working so far, and I&#39;m pretty happy about it. Thanks goes out to Chris and the community.<br><br>My KML consist of points.<br>
<br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;kml xmlns=&quot;<a href="http://earth.google.com/kml/2.1">http://earth.google.com/kml/2.1</a>&quot;&gt;<br>&nbsp; &lt;Document&gt;<br>&nbsp;&nbsp;&nbsp; &lt;Style id=&quot;marker&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;IconStyle&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Icon&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;href&gt;<a href="http://localhost:3000/openlayers/img/marker-green.png">http://localhost:3000/openlayers/img/marker-green.png</a>&lt;/href&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Icon&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/IconStyle&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/Style&gt;<br>&nbsp;&nbsp;&nbsp; &lt;Placemark id=&quot;13856&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;place name&lt;/name&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;description&gt;NULL::character varying&lt;/description&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;styleUrl&gt;#marker&lt;/styleUrl&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Point&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;altitudeMode&gt;relativeToGround&lt;/altitudeMode&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;coordinates&gt;23.29555556,-17.98611111&lt;/coordinates&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/Point&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/Placemark&gt;<br>&nbsp;&nbsp;&nbsp; &lt;Placemark id=&quot;13852&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;place name 2&lt;/name&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;description&gt;NULL::character varying&lt;/description&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;styleUrl&gt;#marker&lt;/styleUrl&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Point&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;altitudeMode&gt;relativeToGround&lt;/altitudeMode&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;coordinates&gt;24.56638889,-17.54027778&lt;/coordinates&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/Point&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/Placemark&gt;<br>&nbsp; &lt;/Document&gt;<br>&lt;/kml&gt;<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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {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>