Skip to content

Commit

Permalink
Fixes geoman-io#147: Redundant coordinate when finish polygon with do…
Browse files Browse the repository at this point in the history
…uble click
  • Loading branch information
Cosme Benito committed Mar 2, 2018
1 parent 8a599dd commit 63e459c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/js/Draw/L.PM.Draw.Poly.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ Draw.Poly = Draw.Line.extend({
this._shape = 'Poly';
this.toolbarButtonName = 'drawPolygon';
},
_finishShape() {
_finishShape(event) {
// if self intersection is not allowed, do not finish the shape!
if (!this.options.allowSelfIntersection && this._doesSelfIntersect) {
return;
}

// get coordinates, create the leaflet shape and add it to the map
const coords = this._layer.getLatLngs();
if (event != null && event.type === 'dblclick') {
// Leaflet creates an extra node with double click
coords.splice(coords.length - 1, 1);
}
const polygonLayer = L.polygon(coords, this.options.pathOptions).addTo(this._map);


// disable drawing
this.disable();

Expand Down

0 comments on commit 63e459c

Please sign in to comment.