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.
.leafletElement
which carries most of the native leaflet properties.You can directly access the Leaflet element created by a component using this.leafletElement in the component. This leaflet element is usually created in componentWillMount() and therefore accessible in componentDidMount(), except for the Map component where it can only be created after the <div> container is rendered.
Components – pilchard