import { MapContainer, Marker, Popup, TileLayer } from 'react-leaflet'
import L from 'leaflet';
import './App.css'
import { useCallback, useState } from 'react';
function App() {
const [coords, setCoords] = useState([0, 0])
const [nextLabel, setNextLabel] = useState("Clicked Marker")
const [markers, setMarkers] = useState([
{label: "Spawn", x:0, y: 0}
])
let map = useCallback((it : L.Map|null) => {
if (it == null) return;
it.on('mousemove', (e) => {setCoords([Math.round(e.latlng.lat), Math.round(e.latlng.lng)])})
it.on('click', (e) => {setMarkers([...markers, {label: nextLabel, x: e.latlng.lng, y: e.latlng.lat}])})
}, [markers, nextLabel]);
return (
<>
Mouse is at {coords[1]}, {-coords[0]}
setNextLabel(e.target.value)} value={nextLabel}/> > ) } export default App