nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit ce527a6bd6cb53010803f054d7bb2866332193e5
parent 2aba6db27fa1d27f1d76f9fc646fc553e69e9e24
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Mon,  6 Mar 2017 00:14:42 +0300

[line edit] avoid exception when editing line and user presses enter key

Diffstat:
Msrc/lib/leaflet.polyline-edit/index.js | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lib/leaflet.polyline-edit/index.js b/src/lib/leaflet.polyline-edit/index.js @@ -82,8 +82,11 @@ L.Polyline.EditMixin = { onMapClick: function(e) { if (this._drawingDirection) { - var newNodeIndex = this._drawingDirection === -1 ? 1 : this.getLatLngs().length - 1; - this.addNode(newNodeIndex, e.latlng); + // click event on map can be from keypress with keycode=13 in which case it doesnot have position + if (e.latlng) { + var newNodeIndex = this._drawingDirection === -1 ? 1 : this.getLatLngs().length - 1; + this.addNode(newNodeIndex, e.latlng); + } } else { if (!this.preventStopEdit) { this.stopEdit();