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 &quot;map.layers[2,3,4]&quot;, 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">&lt;<a href="mailto:crschmidt@metacarta.com">crschmidt@metacarta.com</a>&gt;</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>
&gt; Hi,<br>
&gt; I just wonder how I know if I have OpenLayers 2.8? I have downloaded from<br>
&gt; trunk but the date for OpenLayers.js is 31.03.2009. Or do I have to grab<br>
&gt; some special files. *map.layers* is my arrayname?<br>
&gt;<br>
&gt; I tried your suggestion but when I write:<br>
&gt; selectControl = new OpenLayers.Control.SelectFeature(*map.layers*,{onSelect:<br>
&gt; onFeatureSelect, onUnselect: onFeatureUnselect});<br>
&gt;            map.addControl(selectControl);<br>
&gt;            selectControl.activate();<br>
&gt;            function onPopupClose(evt) {<br>
&gt;                 selectControl.unselect(selectedFeature);<br>
&gt;             }<br>
&gt; I get this error in Firebug and the page is blank:<br>
&gt; *layer.renderer is undefined<br>
&gt; *<br>
&gt; 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>
&gt; /asle<br>
&gt; 2009/6/8 Eric Lemoine &lt;<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>&gt;<br>
&gt;<br>
&gt; &gt; On Sunday, June 7, 2009, Asle Benoni &lt;<a href="mailto:asle.benoni@gmail.com">asle.benoni@gmail.com</a>&gt; wrote:<br>
&gt; &gt; &gt; Hello,<br>
&gt; &gt; &gt; I have a map using a MapFish framework but I think this must be a<br>
&gt; &gt; OpenLayers question.<br>
&gt; &gt; &gt; I have several WFS layers from GeoServer where I use the attributes to<br>
&gt; &gt; fill the popup.  Only problem is that I can only click on markers in one<br>
&gt; &gt; layer at a time. The user sees all the layers, some buildings, another layer<br>
&gt; &gt; with churches etc. but can only click on on layer. How do I solve this? I<br>
&gt; &gt; have now one layer for each type of buildings and I want to be able to turn<br>
&gt; &gt; on and off different buildings so that is why they are in separate layers.<br>
&gt; &gt; Is it possible to still use many layers and bee able to click on popups from<br>
&gt; &gt; different layers. Or is my approach unnecessary difficult? Glad for any<br>
&gt; &gt; help!<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I use this for the WFS layer:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;                 createWfsLayer(<br>
&gt; &gt; &gt;                     &quot;Teknisk industri&quot;,<br>
&gt; &gt; &gt;                     &quot;<br>
&gt; &gt; <a href="http://naturkart.no:8080/geoserver/wfs?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;SRS=EPSG%3A32633&amp;BBOX=40484.8125,6401353.125,760135.8125,6687724.125" target="_blank">http://naturkart.no:8080/geoserver/wfs?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=GetFeature&amp;SRS=EPSG%3A32633&amp;BBOX=40484.8125,6401353.125,760135.8125,6687724.125</a>&quot;,<br>

&gt; &gt; {<br>
&gt; &gt; &gt;                         typename: &quot;kulturminner_ns:tekniskindustrielt&quot;,<br>
&gt; &gt; &gt;                         srsName: &quot;EPSG:32633&quot;,<br>
&gt; &gt; &gt;                         maxfeatures: 200},{<br>
&gt; &gt; &gt;                         extractAttributes:true,<br>
&gt; &gt; &gt;                         visibility:false<br>
&gt; &gt; &gt;                     }<br>
&gt; &gt; &gt;                  );<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; ...same code for each layer....<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; // Popup code, define for each layer with markers:<br>
&gt; &gt; &gt;          selectControl = new<br>
&gt; &gt; OpenLayers.Control.SelectFeature(map.layers[0],{onSelect: onFeatureSelect,<br>
&gt; &gt; onUnselect: onFeatureUnselect});<br>
&gt; &gt; &gt;            map.addControl(selectControl);<br>
&gt; &gt; &gt;            selectControl.activate();<br>
&gt; &gt; &gt;            function onPopupClose(evt) {<br>
&gt; &gt; &gt;                 selectControl1.unselect(selectedFeature);<br>
&gt; &gt; &gt;             }<br>
&gt; &gt; &gt;          selectControl1 = new<br>
&gt; &gt; OpenLayers.Control.SelectFeature(map.layers[1],{onSelect: onFeatureSelect,<br>
&gt; &gt; onUnselect: onFeatureUnselect});<br>
&gt; &gt; &gt;            map.addControl(selectControl1);<br>
&gt; &gt; &gt;            selectControl1.activate();<br>
&gt; &gt; &gt;            function onPopupClose(evt) {<br>
&gt; &gt; &gt;                 selectControl1.unselect(selectedFeature);<br>
&gt; &gt; &gt;             }<br>
&gt; &gt; &gt; // etc...... for every layer with marker<br>
&gt; &gt;<br>
&gt; &gt; Instead of creating one select control for each layer create only one<br>
&gt; &gt; and give it all the layers:<br>
&gt; &gt;<br>
&gt; &gt; sc = new OpenLayers.Control.SelectFeature(array_of_layers, {...});<br>
&gt; &gt;<br>
&gt; &gt; you&#39;ll need OL 2.8 for this (or trunk)<br>
&gt; &gt;<br>
&gt; &gt; Cheers,<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; &gt; // Now the popup functions used:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;         function onFeatureSelect(feature) {<br>
&gt; &gt; &gt;             selectedFeature = feature;<br>
&gt; &gt; &gt;             popup = new OpenLayers.Popup.FramedCloud(&quot;chicken&quot;,<br>
&gt; &gt; &gt;<br>
&gt; &gt; feature.geometry.getBounds().getCenterLonLat(),<br>
&gt; &gt; &gt;                                      new OpenLayers.Size(100,200),<br>
&gt; &gt; &gt;                     &quot;&lt;h2&gt;&quot; +feature.attributes.gardsnavn +<br>
&gt; &gt; &gt;                     &quot;&lt;/h2&gt;Type: &quot;+ feature.attributes.art +<br>
&gt; &gt; &gt;                      &quot;&lt;br /&gt;Kommune: &quot;+ feature.attributes.komm +<br>
&gt; &gt; &gt;                      &quot;&lt;br /&gt;Beskrivelse&lt;br /&gt;&lt;a href=&#39;&quot; +<br>
&gt; &gt; feature.attributes.urltilpdfark +<br>
&gt; &gt; &gt;                      &quot;&#39; target=blank&gt;&lt;img src=&#39;<br>
&gt; &gt; <a href="http://naturkart.no:8080/geoserver/images/logo.png" target="_blank">http://naturkart.no:8080/geoserver/images/logo.png</a>&#39; border=&#39;0&#39;<br>
&gt; &gt; alt=&#39;naturkart&#39;&gt;&lt;/a&gt;&quot;, null, true, onPopupClose);<br>
&gt; &gt; &gt;             feature.popup = popup;<br>
&gt; &gt; &gt;             map.addPopup(popup);<br>
&gt; &gt; &gt;         }<br>
&gt; &gt; &gt;         function onFeatureUnselect(feature) {<br>
&gt; &gt; &gt;             map.removePopup(feature.popup);<br>
&gt; &gt; &gt;             feature.popup.destroy();<br>
&gt; &gt; &gt;             feature.popup = null;<br>
&gt; &gt; &gt;         }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; Eric Lemoine<br>
&gt; &gt;<br>
&gt; &gt; Camptocamp France SAS<br>
&gt; &gt; Savoie Technolac, BP 352<br>
&gt; &gt; 73377 Le Bourget du Lac, Cedex<br>
&gt; &gt;<br>
&gt; &gt; Tel : 00 33 4 79 44 44 96<br>
&gt; &gt; Mail : <a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a><br>
&gt; &gt; <a href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a><br>
&gt; &gt;<br>
<br>
</div></div>&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
&gt; <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>