In data lunedì 24 maggio 2010 15:14:54, Giuseppe Naponiello ha scritto: : > Hi all, > in my project I've 2 layers (layer1, layer2) with different attributes. > Layer 1 is in gml format, layer2 is a txt file > When I click on the layer1, I open a popup with this code: > > function onPopupClose(evt) {selectControl.unselect(feature);} > > //al click su un elemento, creo e visualizzo al popup > function onFeatureSelect(event) { > feature = event.feature; > popup = new OpenLayers.Popup.FramedCloud("chicken", > feature.geometry.getBounds().getCenterLonLat(), > null, > "<div><b>Nome:</b> <a href=\"scheda_comune.php?comune=" + > feature.attributes.NOME + "\" target=\"eastFrame\" > onClick=\"outerLayout.open('east')\">" + feature.attributes.NOME > +"</a></div>", > null, true, onPopupClose); > feature.popup = popup; > map.addPopup(popup); > } > > function onFeatureUnselect(event) { > feature = event.feature; > if (feature.popup){ > map.removePopup(feature.popup); > feature.popup.destroy(); > feature.popup = null; > } > } > .... > > selectControl = new OpenLayers.Control.SelectFeature(layer1); > //{onSelect: onFeatureSelect, onUnselect: onFeatureUnselect}); > layer1.events.on({ > "featureselected": onFeatureSelect, > "featureunselected": onFeatureUnselect > }); > > > Now I'd like to display the same kind of popup for the layer2 but I don't > know what is the correct code to write!!! > > > thanks
Hi, I think that passing both layers to the select control should work: selectControl = new OpenLayers.Control.SelectFeature([layer1, layer2]); selectControl.events.register("featureselected", map, onFeatureSelect); selectControl.events.register("featureunselected", map, onFeatureUnselect); map.addControl(selectControl); selectControl.activate(); -- Alessandro Pasotti itOpen - "Open Solutions for the Net Age" w3: www.itopen.it Linux User# 167502 _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users