[OpenLayers-Users] delete feature & vertexes

George.Muammar george at muammar.net
Tue Aug 5 06:09:04 EDT 2008


I happen to have a snippet handy:

function init(){
    var layer = DEFINE SOME LAYER HERE!!!
    vlayer = new OpenLayers.Layer.Vector( "Editable" );
        map.addLayers([layer, vlayer]);
        var modifyTool = new OpenLayers.Control.ModifyFeature(vlayer);
    var deleteTool = new OpenLayers.Control.SelectFeature(vlayer,
            {
            onSelect:deleteFeature,
             });

     var myControls = [ modifyTool, deleteTool ];

     myControls[0].displayClass = 'olControlSelectFeature';
     myControls[1].displayClass = 'olControlDeleteFeature';

    var editToolBar = new OpenLayers.Control.EditingToolbar(vlayer);
    editToolBar.addControls(myControls);
    map.addControl(editToolBar);
   }

function deleteFeature(feature)
{
feature.layer.destroyFeatures(feature);
}


This problem has been driving me crazy.
btw regarding the "key" solution, I have done it and there are 2
drawbacks...

1. It doesn't work with I.E. - who cares ;-P
2. It doesn't even work with Firefox if you include the Virtual Earth
script. uhm... :-3

Great initiative that of the external control (in fact there is an example
that works like that). But not very elegant from an interface point of view.

Any help will be welcome.
Thanks

George Mu'ammar 



aardelean 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,
> 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
> 
> 

-- 
View this message in context: http://www.nabble.com/delete-feature---vertexes-tp18808997p18828158.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list