I am trying to find coordinates on map when user click on it, but not when he double click to zoom in. The goal being to create a marker at this point and remember it for later.
As I am using svelte, I believe i should use a premade svelte module, I found svelte-leaflet that should be able to do the job.
I downloaded their sample project and start editing from there.
So I just want to get an event so far, so I create a function in App.svelte
const on_map_click = (e) => {
console.log('click')
console.log(e)
}
And add the event handler:
<div class="example" style="width: 100%; height: 100%;">
<LeafletMap bind:this={leafletMap} options={mapOptions} on:click={on_map_click}>
<TileLayer url={tileUrl} options={tileLayerOptions} />
</LeafletMap>
</div>
Unfortunately I don't get any event.
So I tried another aproach (not svelte-oriented) :
onMount(() => {
leafletMap.getMap().fitBounds([[60.9, -4.8], [45.5, 10.2]]);
leafletMap.getMap().on('click', on_map_click) // <---
});
This approach works, but if I double click it still trigger the event. So I believe there is another way, more adapted to the use case.
Please let me know what I am doing wrong ?