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

Add new handler: `src/handlers/runner.js` #254

Closed Raruto closed 1 year ago

Raruto commented 1 year ago

Extract some code from: examples/leaflet-elevation_dynamic-runner.html and move into src/handlers/runner.js

Sample usage:

L.control.Elevation({
  handlers: [ 'Runner' ], // same as: import('https://unpkg.com/@raruto/leaflet-elevation/src/handlers/runner.js')
  runnerOptions: {
    polyline: { .. }, // L.Motion.Polyline control options
    motion: { .. },   // L.Motion.Polyline motion options
    marker: { .. }    // L.Motion.Polyline marker options
  },
});

controlElevation.on('eledata_loaded', ({ layer }) => {
  controlElevation.animate(layer, 1500);
});

Refer to Igor-Vladyka/leaflet.motion#options see for a more comprehensive list of available runnerOptions.

Related to: https://github.com/Raruto/leaflet-elevation/issues/215

Raruto commented 1 year ago

@bard0x here it is a sample integration, let me know if there's something wrong.