diff --git a/js/plugin/Elevation.js b/js/plugin/Elevation.js index e1b61e60..620b0e86 100644 --- a/js/plugin/Elevation.js +++ b/js/plugin/Elevation.js @@ -21,10 +21,9 @@ BR.Elevation = L.Control.Elevation.extend({ } if (track && track.getLatLngs().length > 0) { - // TODO disabled track layer mouseover, as it doesn't really work - // with line marker and indicator does not get removed (no mouseout?) - //this.addData(track.toGeoJSON(), layer); - this.addData(track.toGeoJSON()); + this.addData(track.toGeoJSON(), layer); + + layer.on("mouseout", this._hidePositionMarker.bind(this)); } } }); \ No newline at end of file diff --git a/js/plugin/Routing.js b/js/plugin/Routing.js index 32f1ae16..ba69715b 100644 --- a/js/plugin/Routing.js +++ b/js/plugin/Routing.js @@ -51,6 +51,25 @@ BR.Routing = L.Routing.extend({ ,iconSize: [16, 16] })); + // Forward mousemove event to snapped feature (for Leaflet.Elevation to + // update indicator), see also L.Routing.Edit._segmentOnMousemove + this._edit._mouseMarker.on('move', L.bind(function(e) { + var latLng = e.latlng; + if (latLng._feature) { + this._mouseMarker._feature = latLng._feature; + latLng._feature.fire('mousemove', e); + } + }, this._edit)); + var mouseoutHandler = function(e) { + if (this._mouseMarker._feature) { + this._mouseMarker._feature.fire('mouseout', e); + this._mouseMarker._feature = null; + } + }; + this._edit.on('segment:mouseout', mouseoutHandler, this._edit); + this._edit._mouseMarker.on('dragstart', mouseoutHandler, this._edit); + this.on('waypoint:mouseover', mouseoutHandler, this._edit); + this._draw.on('enabled', function() { // crosshair cursor L.DomUtil.addClass(map.getContainer(), 'routing-draw-enabled');