mpetazzoni / leaflet-gpx

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

Use default Leaflet icon object #136

Open alexpearce opened 1 year ago

alexpearce commented 1 year ago

Rather than having to rely on the icon images in this package being present somewhere, one can use Leaflet's default icon object instead.

const gpx_url = '';
const icon = new L.Icon.Default;
new L.GPX(gpx_url, {
        async: true,
        marker_options: {
            startIcon: icon,
            endIcon: icon,
            wptIcons: {'': icon},
        },
    })
    .on('loaded', (event) => map.fitBounds(event.target.getBounds()))
    .addTo(map);

I wondered if it might make sense to change leaflet-gpx's default icons to leaflet's default icon? This prevents users of the package having to put leaflet-gpx's icons somewhere accessible.

pirex360 commented 1 year ago

Yes, I agree with this possible change.

mjpoo commented 2 weeks ago

I would also be keen to see this feature. I've created a nice little function to use FontAwesome icons as L.DivIcon markers on the map and it would be great to be able to use this approach for GPX waypoints as well. Even being able to use SVG icons rather than bitmaps would be handy.

In the meantime if anyone knows any workarounds or forks I'd be interested.