f5 / unovis

Modular data visualization framework for React, Angular, Svelte, Vue, and vanilla TypeScript or JavaScript
https://unovis.dev
Apache License 2.0
2.27k stars 44 forks source link

Leaflet Map: expose a function showing the current zoom level #327

Open lairdresearch opened 10 months ago

lairdresearch commented 10 months ago

We have functions to control zooming (setZoom, zoomIn, zoomOut) but no function to return the current zoom level of the map. This is hidden in a private variable.

It could be something as simple as:

getZoom() { return this._map.leaflet.getZoom(); }

rokotyan commented 9 months ago

Good point @lairdresearch. We'll add it to our todo list.

Currently, you can get the zoom level from any of the map callback functions, e.g. onMapMoveZoom. Here's the doc section about them: https://unovis.dev/docs/maps/LeafletMap#map-callbacks.

lairdresearch commented 9 months ago

Fair point -- but I'm bundling this together into a Svelte component and it would make binding to variables a lot easier by just being able to query the current zoom to get started. Currently, I have to wait for zoom to be triggered to get the zoom (which triggers the event) so there's a noticeable delay in initializing some components on the side.

rokotyan commented 9 months ago

@lairdresearch I see, thanks for the feedback. We'll let you know once the update is ready.