[OpenLayers-Users] How to - severable clickable WFS layers ?

Asle Benoni asle.benoni at gmail.com
Sun Jun 7 17:49:31 EDT 2009


Hello,
I have a map using a MapFish framework but I think this must be a OpenLayers
question.
I have several WFS layers from GeoServer where I use the attributes to fill
the popup.  Only problem is that I can only click on markers in one layer at
a time. The user sees all the layers, some buildings, another layer with
churches etc. but can only click on on layer. How do I solve this? I have
now one layer for each type of buildings and I want to be able to turn on
and off different buildings so that is why they are in separate layers. Is
it possible to still use many layers and bee able to click on popups from
different layers. Or is my approach unnecessary difficult? Glad for any
help!

I use this for the WFS layer:

                createWfsLayer(
                    "Teknisk industri",
                    "
http://naturkart.no:8080/geoserver/wfs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A32633&BBOX=40484.8125,6401353.125,760135.8125,6687724.125",
{
                        typename: "kulturminner_ns:tekniskindustrielt",
                        srsName: "EPSG:32633",
                        maxfeatures: 200},{
                        extractAttributes:true,
                        visibility:false
                    }
                 );

...same code for each layer....

// Popup code, define for each layer with markers:
         *selectControl *= new OpenLayers.Control.SelectFeature(*
map.layers[0]*,{onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
           map.addControl(*selectControl*);
           *selectControl*.activate();
           function onPopupClose(evt) {
                selectControl1.unselect(selectedFeature);
            }
         *selectControl1* = new OpenLayers.Control.SelectFeature(*
map.layers[1]*,{onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
           map.addControl(*selectControl1*);
           *selectControl1*.activate();
           function onPopupClose(evt) {
                *selectControl1*.unselect(selectedFeature);
            }
// etc...... for every layer with markers
// Now the popup functions used:

        function onFeatureSelect(feature) {
            selectedFeature = feature;
            popup = new OpenLayers.Popup.FramedCloud("chicken",

feature.geometry.getBounds().getCenterLonLat(),
                                     new OpenLayers.Size(100,200),
                    "<h2>" +feature.attributes.gardsnavn +
                    "</h2>Type: "+ feature.attributes.art +
                     "<br />Kommune: "+ feature.attributes.komm +
                     "<br />Beskrivelse<br /><a href='" +
feature.attributes.urltilpdfark +
                     "' target=blank><img src='
http://naturkart.no:8080/geoserver/images/logo.png' border='0'
alt='naturkart'></a>", null, true, onPopupClose);
            feature.popup = popup;
            map.addPopup(popup);
        }
        function onFeatureUnselect(feature) {
            map.removePopup(feature.popup);
            feature.popup.destroy();
            feature.popup = null;
        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090607/8abe0985/attachment.html


More information about the Users mailing list