<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 Arnd,<br><br>thanks for your answer!<br>Please read below.<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="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> </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 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> </div>
<div dir="ltr" align="left"><span class="511545116-26042010"><font color="#0000ff" face="Arial" size="2">The problem is the feature object. You add not a new
feature to a new layer. Instead it seems, that you move the selected
feature from the wfs layer 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> </div></span></div>
<div dir="ltr" align="left"><span class="511545116-26042010"><font color="#0000ff" face="Arial" size="2"> layerWFS.events.on({'featureselected':
function(feature){<br>
selectLayer.addFeatures([feature.feature.clone()]);<br>
//selectLayer.addFeatures([feature.feature]);<br>
alert(this.selectedFeatures.length);<br>
},<br>
'featureunselected':
function(feature){<br>
selectLayer.removeFeatures([selectLayer.features[0]]);<br>
//selectLayer.removeFeatures([feature.feature]);<br>
alert(this.selectedFeatures.length + " -
unselected");<br>
},<br>
});<br></font></span></div>
<div><font face="Arial"><font color="#0000ff"><font size="2"><span class="511545116-26042010"></span></font></font></font> </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>
{ styleMap: styleMap,<br>
strategies: [new
OpenLayers.Strategy.Fixed()],<br>
protocol: new
OpenLayers.Protocol.WFS({ <br><span>
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>
featureNS: "<a rel="nofollow" target="_blank" href="http://mycomp.org">http://mycomp.org</a>",
</span><br>
featureType: "mylayer",
<br>
geometryName: "SHAPE", <br>
srsName: "EPSG:4326",<br>
version: "1.1.0"
<br>
<br>
}),<br>
projection: new OpenLayers.Projection("EPSG:4326")<br>
});
<br><br>wfs2.events.on({'featureselected': function(feature){
<br>
select.addFeatures([feature.feature]); <br>
alert(this.selectedFeatures.length); <br>
}, <br>
'featureunselected': function(feature){<br>
select.removeFeatures([feature.feature]);<br>
alert(this.selectedFeatures.length);
alert("unselected");<br>
},<br>
}); <br><br>var select = new
OpenLayers.Layer.Vector("Selection", { <br>
styleMap: new
OpenLayers.Style(OpenLayers.Feature.Vector.style["select"]),
<br>
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></body></html>