Merge pull request #143 from jorix/stop-freehand

Handler.Path: Stop freehand using "maxVertices"
This commit is contained in:
Éric Lemoine
2012-01-12 12:08:12 -08:00
2 changed files with 45 additions and 3 deletions
+8 -3
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)) {