I'm trying to display the position of the viewer through a marker.
var redIcon = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png',
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
map.locate({setView: true, watch: true, maxZoom: 18});
function onLocationFound(e) {
L.marker(e.latlng, {icon: redIcon}).addTo(map)
}
map.on('locationfound', onLocationFound);
It's clear that watch: true displays the marker, however it does not update each time, but it displays a new marker with a position change. That means, the map is now full of postion markers.
How can I show only one marker when changing my position.