Get Input coordinates to show markers on map in react-leaflet

693 views Asked by At

Can anybody write some code to get input(coordinates) from user to show as marker on map and continue adding markers with new lat,long and option to delete marker too. Please.

I have written this code : enter image description here

1

There are 1 answers

4
ddecrulle On

This code should works, let me know if not.

const [position,setPosition] = useState([]);

const getLocation = () => {
        navigator.geolocation.getCurrentPosition(function(pos) {
            setPosition([pos.coords.latitude,pos.coords.longitude]);
        },);