Sketch handler updates. Patch by tschaub, review elemoine (Closes #1698)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7964 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -59,6 +59,7 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
|
||||
this.polygon.geometry.addComponent(this.line.geometry);
|
||||
this.point = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point());
|
||||
this.layer.addFeatures([this.polygon, this.point], {silent: true});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -67,9 +68,6 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
|
||||
*/
|
||||
destroyFeature: function() {
|
||||
OpenLayers.Handler.Path.prototype.destroyFeature.apply(this);
|
||||
if(this.polygon) {
|
||||
this.polygon.destroy();
|
||||
}
|
||||
this.polygon = null;
|
||||
},
|
||||
|
||||
@@ -93,16 +91,21 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
|
||||
this.layer.drawFeature(this.polygon, this.style);
|
||||
this.layer.drawFeature(this.point, this.style);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: geometryClone
|
||||
* Return a clone of the relevant geometry.
|
||||
* Method: getGeometry
|
||||
* Return the sketch geometry. If <multi> is true, this will return
|
||||
* a multi-part geometry.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Geometry.Polygon>}
|
||||
*/
|
||||
geometryClone: function() {
|
||||
return this.polygon.geometry.clone();
|
||||
getGeometry: function() {
|
||||
var geometry = this.polygon.geometry;
|
||||
if(this.multi) {
|
||||
geometry = new OpenLayers.Geometry.MultiPolygon([geometry]);
|
||||
}
|
||||
return geometry;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -118,6 +121,9 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
|
||||
// remove the penultimate point
|
||||
var index = this.line.geometry.components.length - 2;
|
||||
this.line.geometry.removeComponent(this.line.geometry.components[index]);
|
||||
if(this.persist) {
|
||||
this.destroyPoint();
|
||||
}
|
||||
this.finalize();
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user