<div dir="ltr">Hi,<br><br>Thank you for your message. Yes it works, but...<br><br>I have discovered that this problem is in relation with the modify control I use within the same application. If I rem line for declaring modify control the delete function behaves OK. If I include it, then after delete the vertexes remain. If more than one polygon on map then the vertexes disappear from previous deleted polygon and appear where the last deleted polygon resided.... and so on. On some clicks succession a polygon may be redrawn (with lines and fill style), but no delete or drag or edit may be performed. <br>
<br>&nbsp; var modifyOptions = {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; onModificationStart: function(feature) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenLayers.Console.log(&quot;start modifying&quot;, <a href="http://feature.id">feature.id</a>);<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; onModification: function(feature) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenLayers.Console.log(&quot;modified&quot;, <a href="http://feature.id">feature.id</a>);<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; onModificationEnd: function(feature) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenLayers.Console.log(&quot;end modifying&quot;, <a href="http://feature.id">feature.id</a>);<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; onDelete: function(feature) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenLayers.Console.log(&quot;delete&quot;, <a href="http://feature.id">feature.id</a>);<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; };<br><br>&nbsp;controls = {<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; modify: new OpenLayers.Control.ModifyFeature(vectors, modifyOptions), <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; deletefeature: new OpenLayers.Control.SelectFeature(vectors, {onSelect:deleteFeature}),<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; }; <br><br><br>function deleteFeature(feature) <br>{<br>&nbsp; this.layer.destroyFeatures([feature]);<br>&nbsp; //this.layer.removeFeatures(feature);<br>} <br><br>Any hints how to make delete and modify &quot;cooperate&quot;?<br>
<br>All the best,<br>Adorian<br><br><div class="gmail_quote">On Mon, Aug 4, 2008 at 2:13 PM, Tim Schaub <span dir="ltr">&lt;<a href="mailto:tschaub@opengeo.org">tschaub@opengeo.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey-<br>
<div class="Ih2E3d"><br>
Adorian Ardelean wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; After upgrading to OL 2.6, delete feature function does not work correctly:<br>
&gt; when a polygon or polyline is removed, the lines that define the<br>
&gt; disappear, but the vertexes not (the vertexes appear as the entity is<br>
&gt; selected). The code worked flawlessly in previous version. Is something<br>
&gt; that I have to be aware and/or modify?<br>
&gt;<br>
&gt; declaration of control<br>
&gt; deletefeature: new<br>
&gt; OpenLayers.Control.SelectFeature(vectors,{onSelect:deleteFeature})<br>
&gt;<br>
&gt; delete function<br>
&gt; function deleteFeature(geometry)<br>
&gt; {<br>
&gt; &nbsp; this.layer.removeFeatures(geometry);<br>
&gt; }<br>
&gt;<br>
&gt; Any hint that may solve this issue is appreciated,<br>
<br>
</div>I just tried the following and confirmed that the above works.<br>
<br>
1) open <a href="http://openlayers.org/dev/examples/draw-feature.html" target="_blank">http://openlayers.org/dev/examples/draw-feature.html</a><br>
2) draw a polygon (note freehand is true here)<br>
3) in the firebug console, run this code:<br>
<br>
var del = new OpenLayers.Control.SelectFeature(<br>
 &nbsp; &nbsp; map.layers[3], {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; onSelect: function(feature) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; map.layers[3].removeFeatures([feature]);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; }<br>
);<br>
map.addControl(del);<br>
del.activate();<br>
<br>
4) click on your polygon to see it removed<br>
<br>
I suspect you really want to be calling destroyFeatures instead of<br>
removeFeatures - unless you call feature.destroy elsewhere.<br>
<br>
Tim<br>
<div class="Ih2E3d"><br>
&gt; Adorian<br>
&gt;<br>
&gt; --<br>
&gt; Dr. Adorian Ardelean<br>
&gt; coordinator of myNature Project<br>
&gt;<br>
&gt; proiectul myNature<br>
&gt; str. Rascoala din 1907 nr 12<br>
&gt; Timisoara 300523<br>
&gt; Romania<br>
&gt;<br>
&gt; <a href="http://mybiosis.info/nature/portal.php?pagename=firstpage" target="_blank">http://mybiosis.info/nature/portal.php?pagename=firstpage</a> [a Romanian<br>
&gt; biodiversity-database]<br>
&gt; <a href="http://mybiosis.info/nature/portal.php?pagename=adorian" target="_blank">http://mybiosis.info/nature/portal.php?pagename=adorian</a> [CV]<br>
&gt;<br>
&gt;<br>
</div>&gt; ------------------------------------------------------------------------<br>
&gt;<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>
Users mailing list<br>
<a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Dr. Adorian Ardelean<br>coordinator of myNature Project<br><br>proiectul myNature<br>str. Rascoala din 1907 nr 12<br>Timisoara 300523<br>Romania<br><br><a href="http://mybiosis.info/nature/portal.php?pagename=firstpage">http://mybiosis.info/nature/portal.php?pagename=firstpage</a> [a Romanian biodiversity-database]<br>
<a href="http://mybiosis.info/nature/portal.php?pagename=adorian">http://mybiosis.info/nature/portal.php?pagename=adorian</a> [CV]<br><br>
</div>