[OpenLayers-Users] delete feature & vertexes
Eric Lemoine
eric.c2c at gmail.com
Mon Aug 4 12:27:24 EDT 2008
Hi. Question: How do you distinguish that the user selects a feature
for deletion or modification? I'm trying to understand whether you
need two controls to achieve what you want - using a modify feature
control only might be sufficient and prevent potential problems
because of conflicts between the select feature and modify feature
controls. Cheers. Eric
2008/8/4, Adorian Ardelean <mynature at gmail.com>:
> Hi,
>
> Thank you for your message. Yes it works, but...
>
> 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.
>
>
> var modifyOptions = {
> onModificationStart: function(feature) {
> OpenLayers.Console.log("start modifying", feature.id);
> },
> onModification: function(feature) {
> OpenLayers.Console.log("modified", feature.id);
> },
> onModificationEnd: function(feature) {
> OpenLayers.Console.log("end modifying", feature.id);
> },
> onDelete: function(feature) {
> OpenLayers.Console.log("delete", feature.id);
> }
> };
>
> controls = {
> ...
> modify: new OpenLayers.Control.ModifyFeature(vectors,
> modifyOptions),
> deletefeature: new OpenLayers.Control.SelectFeature(vectors,
> {onSelect:deleteFeature}),
> ...
> };
>
>
> function deleteFeature(feature)
> {
> this.layer.destroyFeatures([feature]);
> //this.layer.removeFeatures(feature);
> }
>
> Any hints how to make delete and modify "cooperate"?
>
> All the best,
> Adorian
>
> On Mon, Aug 4, 2008 at 2:13 PM, Tim Schaub <tschaub at opengeo.org> wrote:
>
>> Hey-
>>
>> Adorian Ardelean wrote:
>> > Hi,
>> >
>> > After upgrading to OL 2.6, delete feature function does not work
>> correctly:
>> > when a polygon or polyline is removed, the lines that define the
>> > disappear, but the vertexes not (the vertexes appear as the entity is
>> > selected). The code worked flawlessly in previous version. Is something
>> > that I have to be aware and/or modify?
>> >
>> > declaration of control
>> > deletefeature: new
>> > OpenLayers.Control.SelectFeature(vectors,{onSelect:deleteFeature})
>> >
>> > delete function
>> > function deleteFeature(geometry)
>> > {
>> > this.layer.removeFeatures(geometry);
>> > }
>> >
>> > Any hint that may solve this issue is appreciated,
>>
>> I just tried the following and confirmed that the above works.
>>
>> 1) open http://openlayers.org/dev/examples/draw-feature.html
>> 2) draw a polygon (note freehand is true here)
>> 3) in the firebug console, run this code:
>>
>> var del = new OpenLayers.Control.SelectFeature(
>> map.layers[3], {
>> onSelect: function(feature) {
>> map.layers[3].removeFeatures([feature]);
>> }
>> }
>> );
>> map.addControl(del);
>> del.activate();
>>
>> 4) click on your polygon to see it removed
>>
>> I suspect you really want to be calling destroyFeatures instead of
>> removeFeatures - unless you call feature.destroy elsewhere.
>>
>> Tim
>>
>> > Adorian
>> >
>> > --
>> > Dr. Adorian Ardelean
>> > coordinator of myNature Project
>> >
>> > proiectul myNature
>> > str. Rascoala din 1907 nr 12
>> > Timisoara 300523
>> > Romania
>> >
>> > http://mybiosis.info/nature/portal.php?pagename=firstpage [a Romanian
>> > biodiversity-database]
>> > http://mybiosis.info/nature/portal.php?pagename=adorian [CV]
>> >
>> >
>> > ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Users mailing list
>> > Users at openlayers.org
>> > http://openlayers.org/mailman/listinfo/users
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>
>
>
> --
> Dr. Adorian Ardelean
> coordinator of myNature Project
>
> proiectul myNature
> str. Rascoala din 1907 nr 12
> Timisoara 300523
> Romania
>
> http://mybiosis.info/nature/portal.php?pagename=firstpage [a Romanian
> biodiversity-database]
> http://mybiosis.info/nature/portal.php?pagename=adorian [CV]
>
More information about the Users
mailing list