I am prompting the user to click to create a single point marker on my map. I need to limit this to only one marker (which must be draggable). I have tried using a count variable with a comparison however this condition is not working for me (the user can make many markers - as shown in this image).
Here is my code:
var count = 0;
if (count <= 0) {
map.on('click', function(e){
count += 1;
var marker = L.marker(e.latlng,{draggable: true}).addTo(map);
var lat = e.latlng.lat;
var lon = e.latlng.lng;
alert("Lat, Lon : " + lat + ", " + lon);
});
}
Thanks in advance.