MrMufflon / Leaflet.Elevation

Leaflet plugin to view height profile of GeoJSON- and GPX polylines using d3
http://mrmufflon.github.io/Leaflet.Elevation
MIT License
276 stars 83 forks source link

Request #68

Open NiekRood opened 7 years ago

NiekRood commented 7 years ago

Is the following possible?

Now hovering the elevation graph will display the current position on the map, but what about the other way around too? Hovering on the map at a specific point will show that exact point at the elevation graph ?

Btw, I am using gpx files

nrenner commented 7 years ago

Yes, this is already implemented, but seems neither to be documented in the readme nor used in the demos.

It only works if addData is called with a second layer parameter that either is null or a Leaflet Layer representing or containing the track.

Martenz commented 7 years ago

I'm actually having the opposite problem .. Implemented as from the example I can hover the track but the graph is not "hoverable" and no indicator on the map .. I'm using Leaflet 1.1.0, bootstrap 4.0alpha. ANy suggestion? thanks

nrenner commented 7 years ago

Probably #67?

Martenz commented 7 years ago

Replaced L.Browser.touch by L.Browser.mobile in leaflet.elevation-0.0.4.min.js. and it works! thanks, sorry my mistake for some reasons I was not able to refresh the cache and the edit didn't took place.. so this fix the problem!

GKKsport commented 6 years ago

@nrenner Could you explain your solution further? I don't fully understand how to add it.

nrenner commented 6 years ago

The addData function needs to get passed the GPX layer g as a second parameter:

var g=new L.GPX("./mytrack.gpx", {async: true});
g.on("addline",function(e){
    //el.addData(e.line);
    el.addData(e.line, g);
});

See modified demo (hover blue line to show position marker in graph): http://plnkr.co/edit/qlmrze0YPdLayxU9Fekb?p=preview

For GeoJSON this already works implicitly when using addData as onEachFeature listener with parameters (feature, layer). See modified demo (online demo uses old 0.0.2 version): http://plnkr.co/edit/v68yhhCA4GSr5VT77ks9?p=preview

fbonzon commented 6 years ago

By default, the marker will remain on the elevation profile after the mouse leaves the GPX/GeoJSON layer on the map.

You can easily modify this by adding a "mouseout" event in addData():

        if (layer) {
            layer.on("mousemove", this._handleLayerMouseOver.bind(this)).
            on("mouseout", this._mouseoutHandler.bind(this));
        }
nrenner commented 6 years ago

See also pending PR #53