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

Empty waypoints at each end of the displayed track #143

Closed fertlon closed 1 year ago

fertlon commented 1 year ago

Hi,

I would like to not display the start and end waypoints of my track, however I have "empty" waypoint icons showing instead of nothing. Here is the HTML code I use :

` // Create the map const map = L.map('map',{fullscreenControl: true}); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map);

// Display the latest position of the ship
const current_position_marker = L.marker([code_snippet id=8 php=true]);
current_position_marker.bindPopup("<b>On est là !</b>").addTo(map).openPopup();

// Display the gpx file
var gpx_file = 'my_track.gpx';
new L.GPX(gpx_file,{
    async: true, 
    gpx_options: {parseElements: 'track'},
    polyline_options: {color: 'green'},
}).on('loaded', function(e) {}).addTo(map);`

I apology if my question is simple, but I did not find the answer in the documentation...

Thank you in advance for your help ! :)

mpetazzoni commented 1 year ago

You should be able to set them to null in the marker_options:

new L.GPX(gpx_file, {
  async: true,
  marker_options: {
    startIconUrl: null,
    endIconUrl: null,
  },
})...

See https://github.com/mpetazzoni/leaflet-gpx/blob/main/gpx.js#L578