Stop freehand using "maxVertices"
This commit is contained in:
@@ -30,8 +30,7 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
|
|||||||
* APIProperty: maxVertices
|
* APIProperty: maxVertices
|
||||||
* {Number} The maximum number of vertices which can be drawn by this
|
* {Number} The maximum number of vertices which can be drawn by this
|
||||||
* handler. When the number of vertices reaches maxVertices, the
|
* handler. When the number of vertices reaches maxVertices, the
|
||||||
* geometry is automatically finalized. This property doesn't
|
* geometry is automatically finalized. Default is null.
|
||||||
* apply if freehand is set. Default is null.
|
|
||||||
*/
|
*/
|
||||||
maxVertices: null,
|
maxVertices: null,
|
||||||
|
|
||||||
@@ -446,7 +445,13 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
|
|||||||
if(this.persist) {
|
if(this.persist) {
|
||||||
this.destroyPersistedFeature();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
if (!this.touch && (!this.mouseDown || this.stoppedDown)) {
|
if (!this.touch && (!this.mouseDown || this.stoppedDown)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user