Hi all, I'm playing a little bit with OpenLayers to build a GIS
prototype for my company, and I need to draw/modify/delete polygons
that I've drawn from myself (so I start from an empty vector layer and
I add geometries using draw functions).
Looks that ModifyControl don't have "remove" functionalities (strange
issue to me, looks a common functionality) that removes the entire
object from the map, but only functions to remove a point inside a
geometry.
So I've extended ModifyControl with this code:
handleKeypress: function(evt) {
// let base method do their work
OpenLayers.Control.ModifyFeature.prototype.handleKeypress.apply(this,
[evt]);
// I've pressed 'delete' buttons over a 'drag' vertice?
var code = evt.keyCode;
if (this.feature && OpenLayers.Util.indexOf(this.deleteCodes,
code) != -1) {
var vertex = this.dragControl.feature;
var index = OpenLayers.Util.indexOf(this.vertices, vertex);
if (vertex && index == -1) {
// pressed on 'drag' vertex, so try to remove feature
var feature = this.feature;
this.unselectFeature(feature);
feature.destroy();
}
}
},
if (vertex && index == -1) returns true if (I hope) I've pressed
delete key over a 'drag' control for a feature, so I can remove the
feature itself from a layer.
Looks working for me, but I fear that I've forgotten some steps. Any
suggestions?
Diego Guidi
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users