Stop freehand using "maxVertices"
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user