mpetazzoni / leaflet-gpx

A GPX track plugin for Leaflet.js
http://mpetazzoni.github.io/leaflet-gpx
BSD 2-Clause "Simplified" License
550 stars 119 forks source link

Uncaught TypeError: can't access property "_toFixed_helper", this is undefined #163

Closed ward closed 2 months ago

ward commented 2 months ago

Presumably this commit is to blame https://github.com/mpetazzoni/leaflet-gpx/commit/92121eaafcfd3e66d4f99926da6feac5f6ec3385. When calling get_speed_data(), I get an error stating that _toFixed_helper is undefined. The error occurs in the loaded event of creating a new L.GPX, I don't know if that matters. Below the code trimmed to (what I believe) are the essentials.

L.GPX(url, { async: true })
.on("loaded", (e) => {
  let speed = e.target.get_speed_data();
}

I am working in a TypeScript file with this library as node modules dependency (currently tracking Git master and Leaflet 1.9.4). Everything gets bundled into one file with webpack. I can provide more context if required.

ward commented 2 months ago

After having another glance, perhaps it can be fixed by changing those this to _this. I do not have the time right now to check whether that behaves as expected.

mpetazzoni commented 2 months ago

I'll take a look, thanks!