[OpenLayers-Users] delete feature & vertexes
Tim Schaub
tschaub at opengeo.org
Mon Aug 4 08:13:18 EDT 2008
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
More information about the Users
mailing list