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

Accessing waypoints #157

Closed mjpoo closed 3 months ago

mjpoo commented 3 months ago

I can get all the track points (trkpt) using event.line.getLatLngs().

Is there a method to get an array of waypoints (wpt) from the GPX file?

I tried getLayers() on loaded but it returns an empty array.

ranran2121 commented 3 months ago

I apologize, I am very new to this. I managed to load a .gpx file from my computer and display the polyline. However, only the start and end points get the markers. I aim to have a a kind of marker of all the trackpoints (or to list them beside the map), in order to delete the points that are clearly wrong.

mjpoo commented 3 months ago

Hi @ranran2121 , I think our issues are different. You can see an example of how to list all your trackpoints using getLatLngs() in issue #145.

mpetazzoni commented 3 months ago

@mjpoo You can listen to addpoint events.

You'll get events with a point_type property which can be start, end, label (named points) and waypoint, and a point property that will be the marker object. You can accumulate them into a list or do whatever you need with them.

HTH! Max