kino_maplibre
kino_maplibre copied to clipboard
Evented API support (moveend)
I need to handle map moveend events (with Kino.MapLibre) but am not sure how to proceed.
Would this require forking/augmenting the project or is the functionality already built-in ?
Hey @gamecubate! It's not built-in. We have implemented only an initial subset of the Maplibre events.
PRs are welcome!
You forgot to ;)
Not sure this can be pulled off, or how.
The idea (frequent use case in my line of work -- dataviz and maps) is for a GET request to be sent to a backend API once and whenever map navigation has ended, say pursuant to a drag and pan action by the user; the query params of the request would include the map bounds of interest.
The way I usually do it with mapboxgl.js is, simplified:
map.on("moveend", refresh);
const refresh = () => {
const resp = await fetch(`${SERVICE_API_URL}/?bounds=${encode(map.getBounds())}`);
const data = await resp.json();
update_map(data);
}
For KinoMapLibre, to keep things flexible, some Ml.on_moveend(map, handler) functionality would be needed and I'm not sure whether (maplibre.js) map instances can communicate with a KinoMapLibre elixir process.
I'll look into it but let me know if this is clearly a non-starter.