<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Hi Alexandre,<br><br>thanks for examples.<br>I went ahead with wfs-getfeature example selecting from a WFS.fromWMSLayer layer (changed this to simple wfs layer because I haven´t got a wms layer at my map right now)- but I get only a response at firebug not at my map because of different projection.<br><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">I have a viewport loading my layers:<br>xtype: "gx_mappanel",<br>map: map,<br>layers: [...,wfs2],<br>...<br>If I use map.addLayers(wfs2) after defining my layer my map is empty (no layers were loaded).<br><br>You said:<br>"unless you add all the vector layers to the SelectFeature control.<br><br>Also,
 you could use only one layer (wfs2) for feature selection instead <br>of
 two."<br>Can I use only one vector layer or more than one?<br><br>best regards<br>Sarah<br><br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;"></span></b><br></font><br>Hi Sarah,<br><br>Have you tried to put your wfs2 layer on top of your layers (as the last <br>one added to the map) ? Only the top-most layer can have its features <br>selected, unless you add all the vector layers to the SelectFeature control.<br><br>Also, you could use only one layer (wfs2) for feature selection instead <br>of two. It seems kinda odd to copy features from one layer to an other <br>for the purpose of "selection". Check the first example about that <br>matter (the other is just to let you know of the cool 'highlight' <br>feature you might be interested into ):<br><a href="http://www.openlayers.org/dev/examples/select-feature.html"
 target="_blank">http://www.openlayers.org/dev/examples/select-feature.html</a><br><a href="http://www.openlayers.org/dev/examples/highlight-feature.html" target="_blank">http://www.openlayers.org/dev/examples/highlight-feature.html</a><br><br>Best regards,<br><br>Alexandre<br><br><br>Sarah Schuessler wrote:<br>&gt; Hi list,<br>&gt; I try to select a feature from a wfs layer but it didn´t work.<br>&gt;<br>&gt; var select = new OpenLayers.Layer.Vector("Selection", {<br>&gt;<br>&gt; styleMap: new<br>&gt;<br>&gt; OpenLayers.StyleMap({strokeColor: "blue",<br>&gt;<br>&gt; strokeWidth: 5 , strokeOpacity: 0.5, fillOpacity: 0.4}),<br>&gt;<br>&gt; displayInLayerSwitcher: true, visibility: true});<br>&gt;<br>&gt; var wfs2 = new OpenLayers.Layer.Vector("WFS_",<br>&gt;<br>&gt; { styleMap: styleMap,<br>&gt;<br>&gt; strategies: [new OpenLayers.Strategy.Fixed()],<br>&gt;<br>&gt; projection: destproj,<br>&gt;<br>&gt; protocol: new
 OpenLayers.Protocol.WFS({<br>&gt;<br>&gt; url: "<a href="http://myserver:81/geoserver/wfs" target="_blank">http://myserver:81/geoserver/wfs</a>",<br>&gt;<br>&gt; featureNS: <a href="http://mycomp.org" target="_blank">http://mycomp.org</a>,<br>&gt;<br>&gt; featureType: "mylayer",<br>&gt;<br>&gt; geometryName: "SHAPE",<br>&gt;<br>&gt; srsName: "EPSG:4326",<br>&gt;<br>&gt; version: "1.1.0"<br>&gt;<br>&gt; }),<br>&gt;<br>&gt; projection: new OpenLayers.Projection("EPSG:4326")<br>&gt;<br>&gt; });<br>&gt;<br>&gt; var selectFeature = new OpenLayers.Control.SelectFeature(wfs2,{box:true});<br>&gt;<br>&gt; //map.addControl(selectFeature);<br>&gt;<br>&gt; selectFeature.events.register("featureselected", this, function(e){<br>&gt;<br>&gt; select.addFeatures([e.feature]); });<br>&gt;<br>&gt; selectFeature.events.register("featureunselected", this, <br>&gt; function(e){select.removeFeatures([e.feature]);});<br>&gt;<br>&gt;  <br>&gt;<br>&gt;
 map.addControl(selectFeature);<br>&gt;<br>&gt; I can cover my feature with a box but then nothing happens. At firebug <br>&gt; I can see that my code never reach "select.addFeatures([e.feature]);".<br>&gt;<br>&gt; If I use:<br>&gt;<br>&gt; selectControl = new OpenLayers.Control.GetFeature({<br>&gt;<br>&gt; protocol: OpenLayers.Protocol.WFS({<br>&gt;<br>&gt; url: "<a href="http://myserver:81/geoserver/wfs?service=wfs" target="_blank">http://myserver:81/geoserver/wfs?service=wfs</a>",<br>&gt;<br>&gt; featureNS: "<a href="http://mycomp.org" target="_blank">http://mycomp.org</a>",<br>&gt;<br>&gt; featureType: "mylayer",<br>&gt;<br>&gt; geometryName: "SHAPE",<br>&gt;<br>&gt; srsName: "EPSG:4326",<br>&gt;<br>&gt; version: "1.0.0",<br>&gt;<br>&gt; }),<br>&gt;<br>&gt; box: true,<br>&gt;<br>&gt; multipleKey: "shiftKey",<br>&gt;<br>&gt; toggleKey: "ctrlKey"<br>&gt;<br>&gt; }, {projection: new OpenLayers.Projection("EPSG:4326")}<br>&gt;<br>&gt; );<br>&gt;<br>&gt;
 selectControl.events.register("featureselected", this, function(e){<br>&gt;<br>&gt; //select.addFeatures(Proj4js.transform(sourceproj,destproj,[e.feature.geometry])); <br>&gt;<br>&gt;<br>&gt; //Proj4js.reportError = <br>&gt; function(msg){alert(msg);}//[e.feature.transform(sourceproj,destproj)]);<br>&gt;<br>&gt; select.addFeatures([e.feature])<br>&gt;<br>&gt; });<br>&gt;<br>&gt; selectControl.events.register("featureunselected", this, <br>&gt; function(e){select.removeFeatures([e.feature]);});<br>&gt;<br>&gt; map.addControl(selectControl);<br>&gt;<br>&gt; I get a response at firebug (but feature has different projection). If <br>&gt; I want to transform my response then I get a message saying "Latitude <br>&gt; failed to converge".<br>&gt;<br>&gt; Features are multipolygon if that does matter.<br>&gt;<br>&gt; What did I wrong?<br>&gt;<br>&gt; Thanks for any hint.<br>&gt;<br>&gt; best regards<br>&gt;<br>&gt; Sarah<br>&gt;<br>&gt;<br>&gt;
 ------------------------------------------------------------------------<br>&gt;<br>&gt; _______________________________________________<br>&gt; Users mailing list<br>&gt; <a ymailto="mailto:Users@openlayers.org" 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>&gt;&nbsp;  <br><br><br>-- <br>Alexandre Dubé<br>Mapgears<br><span><a target="_blank" href="http://www.mapgears.com">www.mapgears.com</a></span><br><br></div></div>
</div><br></body></html>