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/labels.js` #252

Closed Raruto closed 1 year ago

Raruto commented 1 year ago

Sample usage:

L.control.Elevation({
  handlers: [ 'Labels' ], // same as: import('https://unpkg.com/@raruto/leaflet-elevation/src/handlers/labels.js')
  labelsRotation: 25,     // degrees
  labelsAlign: 'start'    // 'start' | 'middle' | 'end'
});

Closes: https://github.com/Raruto/leaflet-elevation/issues/211

Raruto commented 1 year ago

@hupe13 let me know what you think about it

hupe13 commented 1 year ago

In principle it works. But I need to test more. Some things do not seem to work properly.

hupe13 commented 1 year ago

Some things do not seem to work properly.

Maybe it is my special code. It works not correct, if there are more than one map on a page. However, I cannot establish a rule under which conditions what happens, it is not always the same result.

Raruto commented 1 year ago

@hupe13 since dynamic imports are in use here, it is possible that this code still suffers from what is described within: https://github.com/Raruto/leaflet-elevation/pull/253

Basically, all the functions listed here below should first wait for the modules_loaded event before triggering / listening events themselves (with reference to elechart_init and elechart_axis event listeners used within the src/handlers/labels.js)

https://github.com/Raruto/leaflet-elevation/blob/b0006d635a048ec3d1db519819ad3a9813e7ffc6/src/control.js#L247-L255

If so, within your tests, try applying that patch https://github.com/Raruto/leaflet-elevation/pull/253 as well.

👋 Raruto