<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> {<br> var control = controls[key];<br> if(element.value == key && element.checked) <br>
{<br> control.activate();<br> } <br> else <br> {<br> control.deactivate();<br> }<br> }<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 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"><<a href="mailto:eric.c2c@gmail.com">eric.c2c@gmail.com</a>></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'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 <<a href="mailto:mynature@gmail.com">mynature@gmail.com</a>>:<br>
<div><div></div><div class="Wj3C7c">> 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<br>
> use within the same application. If I rem line for declaring modify control<br>
> the delete function behaves OK. If I include it, then after delete the<br>
> vertexes remain. If more than one polygon on map then the vertexes disappear<br>
> from previous deleted polygon and appear where the last deleted polygon<br>
> resided.... and so on. On some clicks succession a polygon may be redrawn<br>
> (with lines and fill style), but no delete or drag or edit may be performed.<br>
><br>
><br>
> var modifyOptions = {<br>
> onModificationStart: function(feature) {<br>
> OpenLayers.Console.log("start modifying", <a href="http://feature.id" target="_blank">feature.id</a>);<br>
> },<br>
> onModification: function(feature) {<br>
> OpenLayers.Console.log("modified", <a href="http://feature.id" target="_blank">feature.id</a>);<br>
> },<br>
> onModificationEnd: function(feature) {<br>
> OpenLayers.Console.log("end modifying", <a href="http://feature.id" target="_blank">feature.id</a>);<br>
> },<br>
> onDelete: function(feature) {<br>
> OpenLayers.Console.log("delete", <a href="http://feature.id" target="_blank">feature.id</a>);<br>
> }<br>
> };<br>
><br>
> controls = {<br>
> ...<br>
> modify: new OpenLayers.Control.ModifyFeature(vectors,<br>
> modifyOptions),<br>
> deletefeature: new OpenLayers.Control.SelectFeature(vectors,<br>
> {onSelect:deleteFeature}),<br>
> ...<br>
> };<br>
><br>
><br>
> function deleteFeature(feature)<br>
> {<br>
> this.layer.destroyFeatures([feature]);<br>
> //this.layer.removeFeatures(feature);<br>
> }<br>
><br>
> Any hints how to make delete and modify "cooperate"?<br>
><br>
> All the best,<br>
> Adorian<br>
><br>
> On Mon, Aug 4, 2008 at 2:13 PM, Tim Schaub <<a href="mailto:tschaub@opengeo.org">tschaub@opengeo.org</a>> wrote:<br>
><br>
>> Hey-<br>
>><br>
>> Adorian Ardelean wrote:<br>
>> > Hi,<br>
>> ><br>
>> > After upgrading to OL 2.6, delete feature function does not work<br>
>> correctly:<br>
>> > when a polygon or polyline is removed, the lines that define the<br>
>> > disappear, but the vertexes not (the vertexes appear as the entity is<br>
>> > selected). The code worked flawlessly in previous version. Is something<br>
>> > that I have to be aware and/or modify?<br>
>> ><br>
>> > declaration of control<br>
>> > deletefeature: new<br>
>> > OpenLayers.Control.SelectFeature(vectors,{onSelect:deleteFeature})<br>
>> ><br>
>> > delete function<br>
>> > function deleteFeature(geometry)<br>
>> > {<br>
>> > this.layer.removeFeatures(geometry);<br>
>> > }<br>
>> ><br>
>> > Any hint that may solve this issue is appreciated,<br>
>><br>
>> 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>
>> map.layers[3], {<br>
>> onSelect: function(feature) {<br>
>> map.layers[3].removeFeatures([feature]);<br>
>> }<br>
>> }<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>
>><br>
>> > Adorian<br>
>> ><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" target="_blank">http://mybiosis.info/nature/portal.php?pagename=firstpage</a> [a Romanian<br>
>> > biodiversity-database]<br>
>> > <a href="http://mybiosis.info/nature/portal.php?pagename=adorian" target="_blank">http://mybiosis.info/nature/portal.php?pagename=adorian</a> [CV]<br>
>> ><br>
>> ><br>
>> > ------------------------------------------------------------------------<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>
>><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>
>><br>
><br>
><br>
><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" target="_blank">http://mybiosis.info/nature/portal.php?pagename=firstpage</a> [a Romanian<br>
> biodiversity-database]<br>
> <a href="http://mybiosis.info/nature/portal.php?pagename=adorian" target="_blank">http://mybiosis.info/nature/portal.php?pagename=adorian</a> [CV]<br>
><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>