leaflet-plugins icon indicating copy to clipboard operation
leaflet-plugins copied to clipboard

little problem when using GPX.js with leaflet elevation plugin

Open emergence75 opened this issue 10 years ago • 3 comments

in layer/vector/GPX.js parse_trkseg: function(line, xml, options, tag) {

at the end of the method i found following...

    var l = [new L.Polyline(coords, options)];

    this.fire('addline', {line:l});
    return l;

when using the elevation plugin the data from the line is accessed via d._latlngs

which brings an error in this case... because it would work with d[0]._latlngs

first i build a workaround in Leaflet.Elevation.0.0.4-src.js

    if (d.length == 1 && (typeof d[0] === 'object') ) { 
        d = d[0];
    }

but after some thinking the correct handling would be to change the code in parse_trkseg: function(line, xml, options, tag) {

    var l = new L.Polyline(coords, options);

    this.fire('addline', {line:l});
    return [l];

after this little change Leaflet.Elevation.0.0.4-src.js works without any further change...

emergence75 avatar Jun 26 '15 14:06 emergence75

Hi @emergence75 i've tested your patch, it works well on gpx example, but it breaks gpx.speed script :\

brunob avatar Jul 13 '15 17:07 brunob

@emergence75 any news about an updated patch for it ?

brunob avatar Dec 01 '15 17:12 brunob

I was trying to adapt gpx.speed script in order to get this one working with your patch, but it's not working for now. I've seen that Leaflet.Elevation use a fork of gpx script that doesn't return the same type of data for _parse_trkseg() :

https://github.com/MrMufflon/Leaflet.Elevation/blob/master/lib/leaflet-gpx/gpx.js#L316 /

This will be hard to maintain compatibility between two forks of the same file... Since leaflet elevation is using a fork of gpx script, in think the "compatibility check" should be done on his side.

Any thoughts about it ?

brunob avatar Dec 03 '15 17:12 brunob