[OpenLayers-Users] display different popup for different layer

Giuseppe Naponiello beppenapo at gmail.com
Mon May 24 09:14:54 EDT 2010


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
-- 
-beppe-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100524/c3e176b8/attachment.html


More information about the Users mailing list