[OpenLayers-Users] delete feature & vertexes

Adorian Ardelean mynature at gmail.com
Mon Aug 4 14:37:10 EDT 2008


Hi Eric,

I have created a toolbox with buttons outside of OL. The tools have two
states on and off (toggleControl).

for(key in controls)
  {
    var control = controls[key];
    if(element.value == key && element.checked)
    {
      control.activate();
    }
    else
    {
      control.deactivate();
    }
  }

where element value is == name of a control as defined in code I indicated
earlier.

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?).

I think this issue is similar to this
http://www.nabble.com/Delete-Feature-td16543538.html#a16543538 if I do not
make a mistake in my interpretation.

All the best,
Adorian



On Mon, Aug 4, 2008 at 6:27 PM, Eric Lemoine <eric.c2c at gmail.com> wrote:

> 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]
> >
>



-- 
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]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080804/9f807018/attachment.html


More information about the Users mailing list