Stop freehand using "maxVertices"

This commit is contained in:
Xavier Mamano
2012-01-12 08:46:15 +01:00
parent a7374db913
commit 70f42b0629

View File

@@ -30,8 +30,7 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
* APIProperty: maxVertices
* {Number} The maximum number of vertices which can be drawn by this
* handler. When the number of vertices reaches maxVertices, the
* geometry is automatically finalized. This property doesn't
* apply if freehand is set. Default is null.
* geometry is automatically finalized. Default is null.
*/
maxVertices: null,
@@ -446,7 +445,13 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
if(this.persist) {
this.destroyPersistedFeature();
}
this.addPoint(evt.xy);
if(this.maxVertices && this.line &&
this.line.geometry.components.length === this.maxVertices) {
this.removePoint()
this.finalize();
} else {
this.addPoint(evt.xy);
}
return false;
}
if (!this.touch && (!this.mouseDown || this.stoppedDown)) {