<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">Hi Arnd,<br><br>thanks for your explanation about styleMap and wms-wfs layer for select control. I thought I could use that with original wfs layer instead of having a wfs.fromwmslayer.<br>I solved my issue with adding a new default and select Style to my wfs layer and remove lines with selectLayer.addFeatures and selectLayer. removeFeatures (so that I can see my wfs styles and not selectlayer select style).<br><div><br>Thanks for your time and help!<br>best regards<br>Sarah<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;"></span></b><br></font><br>

 
<style type="text/css">DIV {
MARGIN:0px;}
</style>


<div dir="ltr" align="left"><span class="712363617-27042010"><font color="#0000ff" face="Arial" size="2">Hi Sarah,</font></span></div>
<div dir="ltr" align="left"><span class="712363617-27042010"><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span class="712363617-27042010"><font color="#0000ff" face="Arial" size="2">the example shows how to retrieve features from a wms 
layer. But you have a vector layer (wfs layer). So you can link the 
SelectFeatureControl to that layer. </font></span></div>
<div>&nbsp;</div>
<div><font color="#0000ff" face="Arial" size="2">ctrlSelectFeatureOptions = { 
clickout: true, toggle: true, multiple: false, hover: false, toggleKey: 
"ctrlKey", multipleKey: "none", box: false };<br>ctrlSelectFeature = new 
OpenLayers.Control.SelectFeature(<span class="712363617-27042010">layerWFS</span>, 
ctrlSelectFeatureOptions);</font></div>
<div><font color="#0000ff" face="Arial" size="2"></font>&nbsp;</div>
<div><span class="712363617-27042010"><font color="#0000ff" face="Arial" size="2">//optional</font></span></div>
<div><font color="#0000ff" face="Arial" size="2">ctrlSelectFeature.onSelect&nbsp;&nbsp;&nbsp; = function (ft) {&nbsp; 
};<br>ctrlSelectFeature.onUnselect&nbsp; = function (ft) {&nbsp; };</font></div>
<div><font color="#0000ff" face="Arial" size="2"></font>&nbsp;</div>
<div><font color="#0000ff" face="Arial" size="2">ctrlSelectFeature.activate();<br></font></div>
<div><font color="#0000ff" face="Arial" size="2"><span class="712363617-27042010">If you 
now click on a feature from your wfs it will be&nbsp;selected. If you do not add 
a own styleMap to your wfs layer, the default styleMap is used to display the 
features for the different modes (unselected, selected or 
temporarily).</span></font></div>
<div><font color="#0000ff" face="Arial" size="2"><span class="712363617-27042010"></span></font>&nbsp;</div>
<div><font><span class="712363617-27042010"></span></font><font color="#0000ff" face="Arial" size="2"><span class="712363617-27042010">If you want use your own 
styleMap, you have to declare the styles for the different modes (at last 
'default' for unselected features and 'select' for selected features) to see 
that you have select a feature.</span></font></div>
<div><font color="#0000ff" face="Arial" size="2"><span class="712363617-27042010"></span></font>&nbsp;</div>
<div><font color="#0000ff" face="Arial" size="2"><span class="712363617-27042010">Arnd</span></font></div>
<div><font color="#0000ff" face="Arial" size="2"><span class="712363617-27042010"></span></font>&nbsp;</div>
<div><font color="#0000ff" face="Arial" size="2"></font>&nbsp;</div>
<div class="OutlookMessageHeader" dir="ltr" align="left" lang="de">
<hr tabindex="-1">
<font face="Tahoma" size="2"><b>Von:</b> Sarah Schuessler 
[mailto:sarah_flip@yahoo.de] <br><b>Gesendet:</b> Dienstag, 27. April 2010 
09:57<br><b>An:</b> Arnd Wippermann<br><b>Cc:</b> 
users@openlayers.org<br><b>Betreff:</b> AW: [OpenLayers-Users] unselect did not 
work<br></font><br></div>
<div></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;">
<div>Hi Arnd,<br><br>thanks for your answer!<br>Please read below.<br></div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><br>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;"><font face="Tahoma" size="2">
<hr size="1">
<b><span style="font-weight: bold;"></span></b><br></font><br>
<style type="text/css">DIV {
MARGIN:0px;}
</style>

<div dir="ltr" align="left"><span class="511545116-26042010"><font color="#0000ff" face="Arial" size="2">Hi,</font></span></div>
<div dir="ltr" align="left"><span class="511545116-26042010"><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span class="511545116-26042010"><font color="#0000ff" face="Arial" size="2">i'm not sure, why you need a layer for your selected 
feature. Why not use the selectFeatureControl on the wfs 
layer.</font></span></div>
<div dir="ltr" align="left"><span class="511545116-26042010"></span><span>I use my 
Control.SelectFeature with my wfs layer(wfs2)- or don`t I use the event right? 
(event.register instead of events.on). I get along with this example: <a rel="nofollow" target="_blank" href="http://dev.openlayers.org/releases/OpenLayers-2.9/examples/getfeature-wfs.html">http://dev.openlayers.org/releases/OpenLayers-2.9/examples/getfeature-wfs.html</a> 
to get back a visual selecting for the user and get back some information about 
the selected feature.</span><br><br></div>
<div dir="ltr" align="left"><span class="511545116-26042010"><font color="#0000ff" face="Arial" size="2">About your question. </font></span></div>
<div dir="ltr" align="left"><span class="511545116-26042010"><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span class="511545116-26042010"><font color="#0000ff" face="Arial" size="2">The problem is the&nbsp;feature object. You add not a new 
feature to a new layer. Instead it seems, that you&nbsp;move the selected 
feature from the wfs layer&nbsp; to the new layer. That means 
wfs.event.on("unselected") cann't work, because your selectFeatureControl works 
only for the wfs layer.</font></span></div>
<div dir="ltr" align="left"><span class="511545116-26042010"></span>Yes I thought 
something like that, but could not manage to solve this. Thanks for your 
example! <br></div>
<div dir="ltr" align="left"><span class="511545116-26042010">
<div dir="ltr" align="left"><span class="511545116-26042010"></span><font face="Arial"><font color="#0000ff"><font size="2">U<span class="511545116-26042010">se a 
clone of the feature and remove the only feature on your select 
layer.</span></font></font></font></div>
<div dir="ltr" align="left"><font face="Arial"><font color="#0000ff"><font size="2"><span class="511545116-26042010"></span></font></font></font>&nbsp;</div></span></div>
<div dir="ltr" align="left"><span class="511545116-26042010"><font color="#0000ff" face="Arial" size="2">&nbsp;&nbsp;&nbsp; layerWFS.events.on({'featureselected': 
function(feature){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
selectLayer.addFeatures([feature.feature.clone()]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//selectLayer.addFeatures([feature.feature]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
alert(this.selectedFeatures.length);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
},<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
'featureunselected': 
function(feature){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
selectLayer.removeFeatures([selectLayer.features[0]]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
//selectLayer.removeFeatures([feature.feature]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
alert(this.selectedFeatures.length + " - 
unselected");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
},<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
});<br></font></span></div>
<div><font face="Arial"><font color="#0000ff"><font size="2"><span class="511545116-26042010"></span></font></font></font>&nbsp;</div>
<div><font face="Arial"><font color="#0000ff"><font size="2"><span class="511545116-26042010">A bit confusing is also the style you add as default 
style to the select layer. It looks like you select a feature on the wfs layer, 
but it's really the not selected feature on the select 
layer.</span></font></font></font></div>
<div><font face="Arial"><font color="#0000ff"><font size="2"><span class="511545116-26042010"></span></font></font></font>So I have to register a 
select style to my wfs layer and cancel select layer, am I right? <br><br>best 
regards<br>Sarah<br></div>
<div><font face="Arial"><font color="#0000ff"><font size="2"><span class="511545116-26042010">Arnd</span></font></font></font></div>
<div dir="ltr" align="left"><br></div>
<div class="OutlookMessageHeader" dir="ltr" align="left" lang="de">
<hr tabindex="-1">
<font face="Tahoma" size="2"><b>Von:</b> users-bounces@openlayers.org 
[mailto:users-bounces@openlayers.org] <b>Im Auftrag von </b>Sarah 
Schuessler<br><b>Gesendet:</b> Montag, 26. April 2010 10:28<br><b>An:</b> 
users@openlayers.org<br><b>Betreff:</b> [OpenLayers-Users] unselect did not 
work<br></font><br></div>
<div></div>
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: times new roman,new york,times,serif;">
<div>Hi list,<br><br>I try to use Control.SelectFeature but I can`t unselect 
(selection layer does not get removed). Here is my code:<br>var selectFeature = 
new OpenLayers.Control.SelectFeature(wfs2, {clickout: true, multiple: false, 
hover: false, toggle:false, toggleKey: "shiftKey", box: true, multipleKey: 
"ctrlKey"});<br><br>var wfs2 = new OpenLayers.Layer.Vector("WFS_Waldschutz", 
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
{ styleMap: styleMap,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;strategies: [new 
OpenLayers.Strategy.Fixed()],<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; protocol: new 
OpenLayers.Protocol.WFS({ <br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; url: "<a rel="nofollow" target="_blank"  href="http://myserver:81/geoserver/wfs?service=wfs">http://myserver:81/geoserver/wfs?service=wfs</a>", 
</span><br><span>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; featureNS: "<a rel="nofollow" target="_blank" href="http://mycomp.org">http://mycomp.org</a>", 
</span><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; featureType: "mylayer", 
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; geometryName: "SHAPE", <br>&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
srsName: "EPSG:4326",<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; version: "1.1.0" 
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }),<br>&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
projection: new OpenLayers.Projection("EPSG:4326")<br>&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; });&nbsp;&nbsp;&nbsp; 
<br><br>wfs2.events.on({'featureselected': function(feature){ 
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
select.addFeatures([feature.feature]); <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; alert(this.selectedFeatures.length); <br>&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; }, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
'featureunselected': function(feature){<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; 
select.removeFeatures([feature.feature]);<br>&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; alert(this.selectedFeatures.length); 
alert("unselected");<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
},<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; });&nbsp; <br><br>var select = new 
OpenLayers.Layer.Vector("Selection", { <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; styleMap: new 
OpenLayers.Style(OpenLayers.Feature.Vector.style["select"]), 
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
displayInLayerSwitcher: true, visibility: true});<br><br>featureselected works 
(at firebug I can see that my app does not get to this break point). What`s 
wrong?<br><br>Thank you for any hints.<br>best 
regards<br>Sarah<br><br></div></div><br></div></div></div><br></div></div>
</div><br></body></html>