<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<STYLE type=text/css>DIV {
        MARGIN: 0px
}
</STYLE>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=511545116-26042010><FONT face=Arial
color=#0000ff size=2>Hi,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=511545116-26042010><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=511545116-26042010><FONT face=Arial
color=#0000ff 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><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=511545116-26042010><FONT face=Arial
color=#0000ff size=2>About your question. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=511545116-26042010><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=511545116-26042010><FONT face=Arial
color=#0000ff 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><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </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 face=Arial
color=#0000ff 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> </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 lang=de dir=ltr align=left>
<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: #000000; 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
href="http://myserver:81/geoserver/wfs?service=wfs"
target=_blank>http://myserver:81/geoserver/wfs?service=wfs</A>",
</SPAN><BR><SPAN>
featureNS: "<A
href="http://mycomp.org" target=_blank>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></BODY></HTML>