Thanks! I forgot to addControl and activate().
map.addControl(selectControl); selectControl.activate(); On 12/03/2008, Christopher Schmidt <[EMAIL PROTECTED]> wrote: > > On Wed, Mar 12, 2008 at 03:26:24PM +0000, Xin wrote: > > Hi, > > > > 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. > > > http://dev.openlayers.org/sandbox/euzuro/pop/examples/sundials.html > > Is a KML example with a selectFeature control and popups. Maybe you > could compare to that and see if it helps you out any. I don't think the > projection will affect things any in this case. > > -- Chris > > > > http://openlayers.org/dev/examples/select-feature.html > > http://openlayers.org/dev/examples/select-feature-openpopup.html > > > > My map is projected. The init code is: > > > > var options = { > > projection: new OpenLayers.Projection("EPSG:900913"), > > displayProjection: new OpenLayers.Projection("EPSG:4326"), > > units: "m", > > maxResolution: 156543.0339, > > maxExtent: new OpenLayers.Bounds(-20037508, -20037508, > > 20037508, 20037508.34), > > restrictedExtent: new OpenLayers.Bounds(-102731.36592167988,- > > 3815736.451414842,3869548.1192908203,-1311047.9090148422) > > }; > > map = new OpenLayers.Map('map', options); > > > > My KML is therefore also projected. The code: > > > > kmlLayer = new OpenLayers.Layer.GML("KML", kmlFeedUrl, > > { > > projection: new OpenLayers.Projection("EPSG:4326"), > > format: OpenLayers.Format.KML, > > formatOptions: { > > extractStyles: true, > > extractAttributes: true > > } > > }); > > > > map.addLayer(kmlLayer); > > > > This is all working so far, and I'm pretty happy about it. Thanks goes > out > > to Chris and the community. > > > > My KML consist of points. > > > > <?xml version="1.0" encoding="UTF-8"?> > > <kml xmlns="http://earth.google.com/kml/2.1"> > > <Document> > > <Style id="marker"> > > <IconStyle> > > <Icon> > > <href>http://localhost:3000/openlayers/img/marker-green.png > </href> > > </Icon> > > </IconStyle> > > </Style> > > <Placemark id="13856"> > > <name>place name</name> > > <description>NULL::character varying</description> > > <styleUrl>#marker</styleUrl> > > <Point> > > <altitudeMode>relativeToGround</altitudeMode> > > <coordinates>23.29555556,-17.98611111</coordinates> > > </Point> > > </Placemark> > > <Placemark id="13852"> > > <name>place name 2</name> > > <description>NULL::character varying</description> > > <styleUrl>#marker</styleUrl> > > <Point> > > <altitudeMode>relativeToGround</altitudeMode> > > <coordinates>24.56638889,-17.54027778</coordinates> > > </Point> > > </Placemark> > > </Document> > > </kml> > > > > 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. > > > > selectControl = new OpenLayers.Control.SelectFeature( kmlLayer, > > {onSelect: onFeatureSelect, onUnselect: > > onFeatureUnselect}); > > > > I also copied over onFeatureSelect and onFeatureUnselect. > > > > When I click on a marker, nothing happens. Do I need to project > > SelectFeature? Does SelectFeature work with Points from a KML file? > > > > Sorry for the long post! Any help is much appreciated. > > > > Xin > > > > _______________________________________________ > > Users mailing list > > [email protected] > > http://openlayers.org/mailman/listinfo/users > > > > -- > Christopher Schmidt > MetaCarta > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users >
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
