kino_maplibre icon indicating copy to clipboard operation
kino_maplibre copied to clipboard

Evented API support (moveend)

Open gamecubate opened this issue 1 year ago • 4 comments

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 ?

gamecubate avatar Nov 29 '23 14:11 gamecubate

Hey @gamecubate! It's not built-in. We have implemented only an initial subset of the Maplibre events.

cristineguadelupe avatar Dec 06 '23 20:12 cristineguadelupe

PRs are welcome!

josevalim avatar Dec 06 '23 21:12 josevalim

You forgot to ;)

gamecubate avatar Dec 06 '23 22:12 gamecubate

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.

gamecubate avatar Dec 08 '23 03:12 gamecubate