Thanks! Sure enough I was mixing in other layers. <br>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.<br>
<br>selectControl = new OpenLayers.Control.SelectFeature(map.layers[2,3,4,5],{onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});<br> map.addControl(selectControl);<br> selectControl.activate();<br>
function onPopupClose(evt) {<br> selectControl.unselect(selectedFeature);<br> }<br><br><div class="gmail_quote">I wonder if this is a good approach for what I want to accomplish? I looked at this example which uses OpenLayers switch features.<br>
<a href="http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group.html">http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group.html</a><br><br>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.<br>
<br>Thanks for any input!!<br><br>/asle<br><br>2009/6/8 Christopher Schmidt <span dir="ltr"><<a href="mailto:crschmidt@metacarta.com">crschmidt@metacarta.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Mon, Jun 08, 2009 at 03:59:03PM +0200, Asle Benoni wrote:<br>
> Hi,<br>
> I just wonder how I know if I have OpenLayers 2.8? I have downloaded from<br>
> trunk but the date for OpenLayers.js is 31.03.2009. Or do I have to grab<br>
> some special files. *map.layers* is my arrayname?<br>
><br>
> I tried your suggestion but when I write:<br>
> selectControl = new OpenLayers.Control.SelectFeature(*map.layers*,{onSelect:<br>
> onFeatureSelect, onUnselect: onFeatureUnselect});<br>
> map.addControl(selectControl);<br>
> selectControl.activate();<br>
> function onPopupClose(evt) {<br>
> selectControl.unselect(selectedFeature);<br>
> }<br>
> I get this error in Firebug and the page is blank:<br>
> *layer.renderer is undefined<br>
> *<br>
> Does this mean I am still using too old OpenLayers.js?<br>
<br>
</div>No. It means you have passed in one or more layers in your array that<br>
are *not* vector layers.<br>
<br>
-- Chris<br>
<div><div></div><div class="h5"><br>
> /asle<br>
> 2009/6/8 Eric Lemoine <<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>><br>
><br>
> > On Sunday, June 7, 2009, Asle Benoni <<a href="mailto:asle.benoni@gmail.com">asle.benoni@gmail.com</a>> wrote:<br>
> > > Hello,<br>
> > > I have a map using a MapFish framework but I think this must be a<br>
> > OpenLayers question.<br>
> > > I have several WFS layers from GeoServer where I use the attributes to<br>
> > fill the popup. Only problem is that I can only click on markers in one<br>
> > layer at a time. The user sees all the layers, some buildings, another layer<br>
> > with churches etc. but can only click on on layer. How do I solve this? I<br>
> > have now one layer for each type of buildings and I want to be able to turn<br>
> > on and off different buildings so that is why they are in separate layers.<br>
> > Is it possible to still use many layers and bee able to click on popups from<br>
> > different layers. Or is my approach unnecessary difficult? Glad for any<br>
> > help!<br>
> > ><br>
> > > I use this for the WFS layer:<br>
> > ><br>
> > > createWfsLayer(<br>
> > > "Teknisk industri",<br>
> > > "<br>
> > <a href="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" target="_blank">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</a>",<br>
> > {<br>
> > > typename: "kulturminner_ns:tekniskindustrielt",<br>
> > > srsName: "EPSG:32633",<br>
> > > maxfeatures: 200},{<br>
> > > extractAttributes:true,<br>
> > > visibility:false<br>
> > > }<br>
> > > );<br>
> > ><br>
> > > ...same code for each layer....<br>
> > ><br>
> > > // Popup code, define for each layer with markers:<br>
> > > selectControl = new<br>
> > OpenLayers.Control.SelectFeature(map.layers[0],{onSelect: onFeatureSelect,<br>
> > onUnselect: onFeatureUnselect});<br>
> > > map.addControl(selectControl);<br>
> > > selectControl.activate();<br>
> > > function onPopupClose(evt) {<br>
> > > selectControl1.unselect(selectedFeature);<br>
> > > }<br>
> > > selectControl1 = new<br>
> > OpenLayers.Control.SelectFeature(map.layers[1],{onSelect: onFeatureSelect,<br>
> > onUnselect: onFeatureUnselect});<br>
> > > map.addControl(selectControl1);<br>
> > > selectControl1.activate();<br>
> > > function onPopupClose(evt) {<br>
> > > selectControl1.unselect(selectedFeature);<br>
> > > }<br>
> > > // etc...... for every layer with marker<br>
> ><br>
> > Instead of creating one select control for each layer create only one<br>
> > and give it all the layers:<br>
> ><br>
> > sc = new OpenLayers.Control.SelectFeature(array_of_layers, {...});<br>
> ><br>
> > you'll need OL 2.8 for this (or trunk)<br>
> ><br>
> > Cheers,<br>
> ><br>
> ><br>
> > > // Now the popup functions used:<br>
> > ><br>
> > > function onFeatureSelect(feature) {<br>
> > > selectedFeature = feature;<br>
> > > popup = new OpenLayers.Popup.FramedCloud("chicken",<br>
> > ><br>
> > feature.geometry.getBounds().getCenterLonLat(),<br>
> > > new OpenLayers.Size(100,200),<br>
> > > "<h2>" +feature.attributes.gardsnavn +<br>
> > > "</h2>Type: "+ feature.attributes.art +<br>
> > > "<br />Kommune: "+ feature.attributes.komm +<br>
> > > "<br />Beskrivelse<br /><a href='" +<br>
> > feature.attributes.urltilpdfark +<br>
> > > "' target=blank><img src='<br>
> > <a href="http://naturkart.no:8080/geoserver/images/logo.png" target="_blank">http://naturkart.no:8080/geoserver/images/logo.png</a>' border='0'<br>
> > alt='naturkart'></a>", null, true, onPopupClose);<br>
> > > feature.popup = popup;<br>
> > > map.addPopup(popup);<br>
> > > }<br>
> > > function onFeatureUnselect(feature) {<br>
> > > map.removePopup(feature.popup);<br>
> > > feature.popup.destroy();<br>
> > > feature.popup = null;<br>
> > > }<br>
> > ><br>
> > ><br>
> > ><br>
> ><br>
> > --<br>
> > Eric Lemoine<br>
> ><br>
> > Camptocamp France SAS<br>
> > Savoie Technolac, BP 352<br>
> > 73377 Le Bourget du Lac, Cedex<br>
> ><br>
> > Tel : 00 33 4 79 44 44 96<br>
> > Mail : <a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a><br>
> > <a href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a><br>
> ><br>
<br>
</div></div>> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
> <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
<font color="#888888"><br>
<br>
--<br>
Christopher Schmidt<br>
MetaCarta<br>
</font></blockquote></div><br>