And to specify the array elements would be? Any help?<br>/asle<br><br><div class="gmail_quote">2009/6/10 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 Wed, Jun 10, 2009 at 01:11:27PM +0200, Asle Benoni wrote:<br>
&gt; Hello,<br>
&gt; I try to specify the layer array like this &quot;map.layers[2,3,4,5]&quot; but that<br>
&gt; does not work. Is this correct?<br>
<br>
</div>This is not corect Javascript syntax in any way that I&#39;m aware of.<br>
<br>
-- Chris<br>
<div><div></div><div class="h5"><br>
&gt; I always get popups only on the last layer I<br>
&gt; have specified. Is my way of specifying the layers array correct? How do I<br>
&gt; check what version of OpenLayers I have?<br>
&gt; A lot of questions! Thanks.<br>
&gt;<br>
&gt; /asle<br>
&gt;<br>
&gt; 2009/6/8 Asle Benoni &lt;<a href="mailto:asle.benoni@gmail.com">asle.benoni@gmail.com</a>&gt;<br>
&gt;<br>
&gt; &gt; Thanks! Sure enough I was mixing in other layers.<br>
&gt; &gt; I chose only the WFS layers now but I am only able to click on the last<br>
&gt; &gt; layer that is listed. If I put &quot;map.layers[2,3,4]&quot;, I get popups for layer 4<br>
&gt; &gt; but no one else.<br>
&gt; &gt;<br>
&gt; &gt; selectControl = new<br>
&gt; &gt; OpenLayers.Control.SelectFeature(map.layers[2,3,4,5],{onSelect:<br>
&gt; &gt; onFeatureSelect, onUnselect: onFeatureUnselect});<br>
&gt; &gt;            map.addControl(selectControl);<br>
&gt; &gt;            selectControl.activate();<br>
&gt; &gt;            function onPopupClose(evt) {<br>
&gt; &gt;                 selectControl.unselect(selectedFeature);<br>
&gt; &gt;             }<br>
&gt; &gt;<br>
&gt; &gt; I wonder if this is a good approach for what I want to accomplish? I looked<br>
&gt; &gt; at this example which uses OpenLayers switch features.<br>
&gt; &gt;<br>
&gt; &gt; <a href="http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group.html" target="_blank">http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group.html</a><br>
&gt; &gt;<br>
&gt; &gt; I would else have to hide a layer when another is shown since users would<br>
&gt; &gt; not understand why every marker in all visible layers are not clickable.<br>
&gt; &gt;<br>
&gt; &gt; Thanks for any input!!<br>
&gt; &gt;<br>
&gt; &gt; /asle<br>
&gt; &gt;<br>
&gt; &gt; 2009/6/8 Christopher Schmidt &lt;<a href="mailto:crschmidt@metacarta.com">crschmidt@metacarta.com</a>&gt;<br>
&gt; &gt;<br>
&gt; &gt; On Mon, Jun 08, 2009 at 03:59:03PM +0200, Asle Benoni wrote:<br>
&gt; &gt;&gt; &gt; Hi,<br>
&gt; &gt;&gt; &gt; I just wonder how I know if I have OpenLayers 2.8? I have downloaded<br>
&gt; &gt;&gt; from<br>
&gt; &gt;&gt; &gt; trunk but the date for OpenLayers.js is 31.03.2009. Or do I have to grab<br>
&gt; &gt;&gt; &gt; some special files. *map.layers* is my arrayname?<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &gt; I tried your suggestion but when I write:<br>
&gt; &gt;&gt; &gt; selectControl = new<br>
&gt; &gt;&gt; OpenLayers.Control.SelectFeature(*map.layers*,{onSelect:<br>
&gt; &gt;&gt; &gt; onFeatureSelect, onUnselect: onFeatureUnselect});<br>
&gt; &gt;&gt; &gt;            map.addControl(selectControl);<br>
&gt; &gt;&gt; &gt;            selectControl.activate();<br>
&gt; &gt;&gt; &gt;            function onPopupClose(evt) {<br>
&gt; &gt;&gt; &gt;                 selectControl.unselect(selectedFeature);<br>
&gt; &gt;&gt; &gt;             }<br>
&gt; &gt;&gt; &gt; I get this error in Firebug and the page is blank:<br>
&gt; &gt;&gt; &gt; *layer.renderer is undefined<br>
&gt; &gt;&gt; &gt; *<br>
&gt; &gt;&gt; &gt; Does this mean I am still using too old OpenLayers.js?<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; No. It means you have passed in one or more layers in your array that<br>
&gt; &gt;&gt; are *not* vector layers.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; -- Chris<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; &gt; /asle<br>
&gt; &gt;&gt; &gt; 2009/6/8 Eric Lemoine &lt;<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>&gt;<br>
&gt; &gt;&gt; &gt;<br>
&gt; &gt;&gt; &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; &gt; &gt; &gt; Hello,<br>
&gt; &gt;&gt; &gt; &gt; &gt; I have a map using a MapFish framework but I think this must be a<br>
&gt; &gt;&gt; &gt; &gt; OpenLayers question.<br>
&gt; &gt;&gt; &gt; &gt; &gt; I have several WFS layers from GeoServer where I use the attributes<br>
&gt; &gt;&gt; to<br>
&gt; &gt;&gt; &gt; &gt; fill the popup.  Only problem is that I can only click on markers in<br>
&gt; &gt;&gt; one<br>
&gt; &gt;&gt; &gt; &gt; layer at a time. The user sees all the layers, some buildings, another<br>
&gt; &gt;&gt; layer<br>
&gt; &gt;&gt; &gt; &gt; with churches etc. but can only click on on layer. How do I solve<br>
&gt; &gt;&gt; this? I<br>
&gt; &gt;&gt; &gt; &gt; have now one layer for each type of buildings and I want to be able to<br>
&gt; &gt;&gt; turn<br>
&gt; &gt;&gt; &gt; &gt; on and off different buildings so that is why they are in separate<br>
&gt; &gt;&gt; layers.<br>
&gt; &gt;&gt; &gt; &gt; Is it possible to still use many layers and bee able to click on<br>
&gt; &gt;&gt; popups from<br>
&gt; &gt;&gt; &gt; &gt; different layers. Or is my approach unnecessary difficult? Glad for<br>
&gt; &gt;&gt; any<br>
&gt; &gt;&gt; &gt; &gt; help!<br>
&gt; &gt;&gt; &gt; &gt; &gt;<br>
&gt; &gt;&gt; &gt; &gt; &gt; I use this for the WFS layer:<br>
&gt; &gt;&gt; &gt; &gt; &gt;<br>
&gt; &gt;&gt; &gt; &gt; &gt;                 createWfsLayer(<br>
&gt; &gt;&gt; &gt; &gt; &gt;                     &quot;Teknisk industri&quot;,<br>
&gt; &gt;&gt; &gt; &gt; &gt;                     &quot;<br>
&gt; &gt;&gt; &gt; &gt;<br>
&gt; &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><br>

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