"perhaps using a conditional with respective check boxes?" To use the same functions for different layers, I use a dropdownlist to set the active layer http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/labels.html
and in a second example I have enhanced the layerswitcher to set a layer active and then can execute functions for this layer. http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/labels_radiobtn.htm l Arnd Wippermann -----Ursprüngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von [EMAIL PROTECTED] Gesendet: Montag, 29. September 2008 19:17 An: [email protected] Betreff: [OpenLayers-Users] Pop-Up Sample Working on Multiple KML Layers Hi, Wanted to send this out again as I never got any replies. Thanks in advance! Jeff ---------------------------------------------- Hi, I'm using the "generic" pop-up sample in my OL application. I have four KML files on top of a Yahoo backdrop. I'd like to be able to click on any one of the four KML layers and have a pop-up showing me the respective attributes. The pop-up sample does this for one layer. Is there a way to implement for more than one layer? If so, would anybody by chance have some sample code they could point me to? If not, any suggested workarounds, perhaps using a conditional with respective check boxes? I've pasted the pop-up code below for reference. Thanks in advance to all! Jeff ================================= // This is the pop-up logic selectControl = new OpenLayers.Control.SelectFeature(map.layers[3], { // Need to get this to work on multiple layers! onSelect: onFeatureSelect, onUnselect: onFeatureUnselect }) map.addControl(selectControl); selectControl.activate(); function onPopupClose(evt){ selectControl.unselect(selectedFeature); } function onFeatureSelect(feature){ selectedFeature = feature; popup = new OpenLayers.Popup.FramedCloud("chicken", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(100, 100), "<h2>" + feature.attributes.name + "</h2>" + "<h2>" + feature.attributes.description + "</h2>", null, true, onPopupClose); popup.border = '1px solid black'; popup.opacity = .8; popup.autoSize = true; popup.panMapIfOutOfView = true; feature.popup = popup; map.addPopup(popup); } function onFeatureUnselect(feature){ map.removePopup(feature.popup); feature.popup.destroy(); feature.popup = null; } _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
