Skip to content

Commit

Permalink
Show position in elevation diagram when hovering path on map, closes #29
Browse files Browse the repository at this point in the history
  • Loading branch information
nrenner committed Jun 21, 2016
1 parent 83ce7ff commit 42d04e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 3 additions & 4 deletions js/plugin/Elevation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
});
19 changes: 19 additions & 0 deletions js/plugin/Routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 42d04e5

Please sign in to comment.