From 7098cd2cf3474cbc4f85cf30ccf427231e9ac7de Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Wed, 27 May 2015 20:06:57 +0200 Subject: [PATCH] fix adding new waypoint after deleting the last --- js/plugin/Routing.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/plugin/Routing.js b/js/plugin/Routing.js index 8dc4761..45463a2 100644 --- a/js/plugin/Routing.js +++ b/js/plugin/Routing.js @@ -1,3 +1,9 @@ +L.Routing.Draw.prototype._hideTrailer = function() { + if (this._trailer.options.opacity !== 0.0) { + this._trailer.setStyle({opacity: 0.0}); + } +}; + BR.Routing = L.Routing.extend({ options: { position: 'topright', @@ -89,6 +95,18 @@ BR.Routing = L.Routing.extend({ L.DomEvent.off(this._map._controlContainer, 'mouseover', hide, this); }); + // Call show after deleting last waypoint, but hide trailer. + // Gets hidden in _catchWaypointEvent on waypoint mouseover, but + // mouseout to show again never fires when deleted. Click handler + // _onMouseClick aborts when hidden, so no waypoint can be added + // although enabled. + this.on('waypoint:click', function() { + if (this._hidden && !this._parent._waypoints._first) { + this._show(); + this._hideTrailer(); + } + }, this._draw); + // enable drawing mode this.draw(true);