Raruto / leaflet-elevation

Leaflet plugin that allows to add elevation profiles using d3js
GNU General Public License v3.0
254 stars 82 forks source link

Custom Start and End marker icons using the `"eledata_loaded"` event #239

Closed haldo98 closed 1 year ago

haldo98 commented 1 year ago

Thank you for your great work.

I'm a newbie in js so please forgive me if I'm writing something dumb

I have some issue with the gpxOptions inherited from leaflet-gpx

I added the options #18 of the marker from leaflet-gpx but the markers are not shown.

gpxOptions: {
marker_options: {
    startIconUrl: 'pin-icon-start.png',
    endIconUrl: 'pin-icon-end.png',
    shadowUrl: 'pin-shadow.png'
    },
},

Here is my working example: https://www.tadini.it/temp/map.html

And..... does the event from leaflet-gpx is supported? (addpoint - loaded - error )

Thank You.

Raruto commented 1 year ago

In the latest versions of this library the lealfet-gpx dependency has been removed.

BTW, if you don't want to go crazy understanding too much third party code you can also do it directly adding two simple L.Markers (at the start and end of your path).

👋 Raruto

haldo98 commented 1 year ago

Thank you.... is there a way to directly point to the start (and maybe also to the end) of the track with the plugin or should I have one or two waypoints ? (start-end)

thank u

Raruto commented 1 year ago

I think there are several ways to achieve this, just FYI, here you can change the properties related to the current start and end icons (if I remember correctly, even if they are L.CircleMarkers with a little imagination, you could also use raster icons, in case please search for this on the web and let me know..)

https://github.com/Raruto/leaflet-elevation/blob/868179234d8e9b8f7beaea57d0e34d8bd79a2622/src/options.js#L52-L53

Otherwise here it is something old-fashioned:

controlElevation.on('eledata_loaded', (e) => {
  console.log(e, controlElevation._data); // <-- here you can do something much more clever.. 😃
);

controlElevation.load(url);

👋 Raruto