<div dir="ltr">Hi Eric,<br><br>I have created a toolbox with buttons outside of OL. The tools have two states on and off (toggleControl). <br><br>for(key in controls) <br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; var control = controls[key];<br>&nbsp;&nbsp;&nbsp; if(element.value == key &amp;&amp; element.checked) <br>
&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; control.activate();<br>&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp; else <br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; control.deactivate();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br><br>where element value is == name of a control as defined in code I indicated earlier.<br><br>If delete button is selected a click on an entity removes it from layer; if edit button is selected then a click on an entity makes if enter modify mode. I think I need both of them, but if you have suggestions on how to combine delete and modify under the same modify control&nbsp; please let me know (use of keys?). <br>
<br>I think this issue is similar to this <a href="http://www.nabble.com/Delete-Feature-td16543538.html#a16543538">http://www.nabble.com/Delete-Feature-td16543538.html#a16543538</a> if I do not make a mistake in my interpretation.<br>
<br>All the best,<br>Adorian<br><br><br><br><div class="gmail_quote">On Mon, Aug 4, 2008 at 6:27 PM, Eric Lemoine <span dir="ltr">&lt;<a href="mailto:eric.c2c@gmail.com">eric.c2c@gmail.com</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;">
Hi. Question: How do you distinguish that the user selects a feature<br>
for deletion or modification? I&#39;m trying to understand whether you<br>
need two controls to achieve what you want - using a modify feature<br>
control only might be sufficient and prevent potential problems<br>
because of conflicts between the select feature and modify feature<br>
controls. Cheers. Eric<br>
<br>
2008/8/4, Adorian Ardelean &lt;<a href="mailto:mynature@gmail.com">mynature@gmail.com</a>&gt;:<br>
<div><div></div><div class="Wj3C7c">&gt; Hi,<br>
&gt;<br>
&gt; Thank you for your message. Yes it works, but...<br>
&gt;<br>
&gt; I have discovered that this problem is in relation with the modify control I<br>
&gt; use within the same application. If I rem line for declaring modify control<br>
&gt; the delete function behaves OK. If I include it, then after delete the<br>
&gt; vertexes remain. If more than one polygon on map then the vertexes disappear<br>
&gt; from previous deleted polygon and appear where the last deleted polygon<br>
&gt; resided.... and so on. On some clicks succession a polygon may be redrawn<br>
&gt; (with lines and fill style), but no delete or drag or edit may be performed.<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; var modifyOptions = {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onModificationStart: function(feature) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OpenLayers.Console.log(&quot;start modifying&quot;, <a href="http://feature.id" target="_blank">feature.id</a>);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onModification: function(feature) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OpenLayers.Console.log(&quot;modified&quot;, <a href="http://feature.id" target="_blank">feature.id</a>);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onModificationEnd: function(feature) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OpenLayers.Console.log(&quot;end modifying&quot;, <a href="http://feature.id" target="_blank">feature.id</a>);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onDelete: function(feature) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OpenLayers.Console.log(&quot;delete&quot;, <a href="http://feature.id" target="_blank">feature.id</a>);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };<br>
&gt;<br>
&gt; &nbsp;controls = {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; modify: new OpenLayers.Control.ModifyFeature(vectors,<br>
&gt; modifyOptions),<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; deletefeature: new OpenLayers.Control.SelectFeature(vectors,<br>
&gt; {onSelect:deleteFeature}),<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };<br>
&gt;<br>
&gt;<br>
&gt; function deleteFeature(feature)<br>
&gt; {<br>
&gt; &nbsp; this.layer.destroyFeatures([feature]);<br>
&gt; &nbsp; //this.layer.removeFeatures(feature);<br>
&gt; }<br>
&gt;<br>
&gt; Any hints how to make delete and modify &quot;cooperate&quot;?<br>
&gt;<br>
&gt; All the best,<br>
&gt; Adorian<br>
&gt;<br>
&gt; On Mon, Aug 4, 2008 at 2:13 PM, Tim Schaub &lt;<a href="mailto:tschaub@opengeo.org">tschaub@opengeo.org</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; Hey-<br>
&gt;&gt;<br>
&gt;&gt; Adorian Ardelean wrote:<br>
&gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; After upgrading to OL 2.6, delete feature function does not work<br>
&gt;&gt; correctly:<br>
&gt;&gt; &gt; when a polygon or polyline is removed, the lines that define the<br>
&gt;&gt; &gt; disappear, but the vertexes not (the vertexes appear as the entity is<br>
&gt;&gt; &gt; selected). The code worked flawlessly in previous version. Is something<br>
&gt;&gt; &gt; that I have to be aware and/or modify?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; declaration of control<br>
&gt;&gt; &gt; deletefeature: new<br>
&gt;&gt; &gt; OpenLayers.Control.SelectFeature(vectors,{onSelect:deleteFeature})<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; delete function<br>
&gt;&gt; &gt; function deleteFeature(geometry)<br>
&gt;&gt; &gt; {<br>
&gt;&gt; &gt; &nbsp; this.layer.removeFeatures(geometry);<br>
&gt;&gt; &gt; }<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Any hint that may solve this issue is appreciated,<br>
&gt;&gt;<br>
&gt;&gt; I just tried the following and confirmed that the above works.<br>
&gt;&gt;<br>
&gt;&gt; 1) open <a href="http://openlayers.org/dev/examples/draw-feature.html" target="_blank">http://openlayers.org/dev/examples/draw-feature.html</a><br>
&gt;&gt; 2) draw a polygon (note freehand is true here)<br>
&gt;&gt; 3) in the firebug console, run this code:<br>
&gt;&gt;<br>
&gt;&gt; var del = new OpenLayers.Control.SelectFeature(<br>
&gt;&gt; &nbsp; &nbsp; map.layers[3], {<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; onSelect: function(feature) {<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; map.layers[3].removeFeatures([feature]);<br>
&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt;&gt; &nbsp; &nbsp; }<br>
&gt;&gt; );<br>
&gt;&gt; map.addControl(del);<br>
&gt;&gt; del.activate();<br>
&gt;&gt;<br>
&gt;&gt; 4) click on your polygon to see it removed<br>
&gt;&gt;<br>
&gt;&gt; I suspect you really want to be calling destroyFeatures instead of<br>
&gt;&gt; removeFeatures - unless you call feature.destroy elsewhere.<br>
&gt;&gt;<br>
&gt;&gt; Tim<br>
&gt;&gt;<br>
&gt;&gt; &gt; Adorian<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; --<br>
&gt;&gt; &gt; Dr. Adorian Ardelean<br>
&gt;&gt; &gt; coordinator of myNature Project<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; proiectul myNature<br>
&gt;&gt; &gt; str. Rascoala din 1907 nr 12<br>
&gt;&gt; &gt; Timisoara 300523<br>
&gt;&gt; &gt; Romania<br>
&gt;&gt; &gt;<br>
&gt;&gt; &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;&gt; &gt; biodiversity-database]<br>
&gt;&gt; &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;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; ------------------------------------------------------------------------<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; Users mailing list<br>
&gt;&gt; &gt; <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
&gt;&gt; &gt; <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Users mailing list<br>
&gt;&gt; <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
&gt;&gt; <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<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>
</div></div></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>
</div>