Thanks!<br><br>I forgot to addControl and activate().<br><br><pre id="line1">map.addControl(selectControl);<br>selectControl.activate(); </pre><br><br><div><span class="gmail_quote">On 12/03/2008, <b class="gmail_sendername">Christopher Schmidt</b> <<a href="mailto:crschmidt@metacarta.com">crschmidt@metacarta.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wed, Mar 12, 2008 at 03:26:24PM +0000, Xin wrote:<br> > Hi,<br> ><br> > I have a KML layer which I want to be able to click and see a pop up. I am<br> > following the following examples, but it's not working for me.<br>
<br> <br><a href="http://dev.openlayers.org/sandbox/euzuro/pop/examples/sundials.html">http://dev.openlayers.org/sandbox/euzuro/pop/examples/sundials.html</a><br> <br> Is a KML example with a selectFeature control and popups. Maybe you<br>
could compare to that and see if it helps you out any. I don't think the<br> projection will affect things any in this case.<br> <br> -- Chris<br> <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,-<br>
> 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<br> > 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<br> > window consisting of name and description. After this KML layer is added, I<br>
> add a select control as suggested from Vector file popup examples.<br> ><br> > selectControl = new OpenLayers.Control.SelectFeature( kmlLayer,<br> > {onSelect: onFeatureSelect, onUnselect:<br>
> 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<br> > 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> <br>> _______________________________________________<br> > Users mailing list<br> > <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
> <a href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</a><br> <br><br> <br> --<br> Christopher Schmidt<br> MetaCarta<br> _______________________________________________<br>
Users mailing list<br> <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br> <a href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</a><br> </blockquote></div><br>