[OpenLayers-Users] How to - severable clickable WFS layers ?
Asle Benoni
asle.benoni at gmail.com
Mon Jun 8 11:23:47 EDT 2009
Thanks! Sure enough I was mixing in other layers.
I chose only the WFS layers now but I am only able to click on the last
layer that is listed. If I put "map.layers[2,3,4]", I get popups for layer 4
but no one else.
selectControl = new
OpenLayers.Control.SelectFeature(map.layers[2,3,4,5],{onSelect:
onFeatureSelect, onUnselect: onFeatureUnselect});
map.addControl(selectControl);
selectControl.activate();
function onPopupClose(evt) {
selectControl.unselect(selectedFeature);
}
I wonder if this is a good approach for what I want to accomplish? I looked
at this example which uses OpenLayers switch features.
http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group.html
I would else have to hide a layer when another is shown since users would
not understand why every marker in all visible layers are not clickable.
Thanks for any input!!
/asle
2009/6/8 Christopher Schmidt <crschmidt at metacarta.com>
> On Mon, Jun 08, 2009 at 03:59:03PM +0200, Asle Benoni wrote:
> > Hi,
> > I just wonder how I know if I have OpenLayers 2.8? I have downloaded from
> > trunk but the date for OpenLayers.js is 31.03.2009. Or do I have to grab
> > some special files. *map.layers* is my arrayname?
> >
> > I tried your suggestion but when I write:
> > selectControl = new
> OpenLayers.Control.SelectFeature(*map.layers*,{onSelect:
> > onFeatureSelect, onUnselect: onFeatureUnselect});
> > map.addControl(selectControl);
> > selectControl.activate();
> > function onPopupClose(evt) {
> > selectControl.unselect(selectedFeature);
> > }
> > I get this error in Firebug and the page is blank:
> > *layer.renderer is undefined
> > *
> > Does this mean I am still using too old OpenLayers.js?
>
> No. It means you have passed in one or more layers in your array that
> are *not* vector layers.
>
> -- Chris
>
> > /asle
> > 2009/6/8 Eric Lemoine <eric.lemoine at camptocamp.com>
> >
> > > On Sunday, June 7, 2009, Asle Benoni <asle.benoni at gmail.com> wrote:
> > > > 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 marker
> > >
> > > Instead of creating one select control for each layer create only one
> > > and give it all the layers:
> > >
> > > sc = new OpenLayers.Control.SelectFeature(array_of_layers, {...});
> > >
> > > you'll need OL 2.8 for this (or trunk)
> > >
> > > Cheers,
> > >
> > >
> > > > // 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;
> > > > }
> > > >
> > > >
> > > >
> > >
> > > --
> > > Eric Lemoine
> > >
> > > Camptocamp France SAS
> > > Savoie Technolac, BP 352
> > > 73377 Le Bourget du Lac, Cedex
> > >
> > > Tel : 00 33 4 79 44 44 96
> > > Mail : eric.lemoine at camptocamp.com
> > > http://www.camptocamp.com
> > >
>
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
>
>
> --
> Christopher Schmidt
> MetaCarta
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090608/bd0d1596/attachment.html
More information about the Users
mailing list