Hello, I have got map component that looks like that :
<Map mapStyle=”[map api json key]” mapProps={{ center: [19.4486, 51.759493], zoom: 10 }}> </Map>;
and I want to add to it listener, that on the click on the map will retrieve current position.
I’ve found library with this (example from documentation, there is just this)
export const Example = () => { useMapEvent(‘click’, e => { console.log(e.lngLat); }) return null; }
but I have got no idea how to combine it with my map.
I have map initialized like <Map> </Map> and all tutorials are initialized like
map = new mapboxgl.Map (map parameters)
Doing it this way allows you to refer to the map by variable name, e.g. map.on (action), and how do you add a function to a map that is <Map> </Map> initialized? I am trying to add this listener on click and I don’t know how
submitted by /u/Confident_Roof7310
[link] [comments]