Leaflet.Elevation icon indicating copy to clipboard operation
Leaflet.Elevation copied to clipboard

Uncaught TypeError when calling addData with only one parameter

Open electriclarry opened this issue 8 years ago • 0 comments

First of all, thanks a lot for this sweet leaflet plugin!

When running your example_gpx.html I can see the elevation graph but no map. The javascript console shows the error:

Uncaught TypeError: Cannot read property 'on' of undefined on line 616 in Leaflet.Elevation-0.0.2.src.js

The exception is thrown after calling el.addData like suggested in your README and the examples like this:

g.on("addline",function(e)
{
	el.addData(e.line);
});

In order to prevent this error I had to pass the gpx-layer object as second parameter to the addData function call like this:

var track = new L.GPX("./example.gpx",
{
	async: true
});

track.on("addline", function(e)
{
	el.addData(e.line, track);
});

electriclarry avatar Nov 24 '16 21:11 electriclarry