I'm trying to get the latitude and longitude of a marker in react-leaflet, but can't seem to figure out how. In Leaflet, there is a function for it but I can't figure out how to call that in react-leaflet.
My goal is to have a marker on the map (fixed location) and another draggable one. When you drag the marker, it will print the coordinates to console onDragEnd and then tell you the distance between the two. I've been reading the documentation and looking at the code, but can't seem to implement this in my React component.
Any help is greatly appreciated.
As per the react-leaflet component docs:
Components
Here's a quick minimal example which assigns a
ref
to the marker and watches for thedragEnd
event.React-Leaflet example