I am using Leaflet to display a map in Angular8. I want to add a marker to the clicked location. Everything works fine, except the fact that a marker is being added after I finish dragging the map, and I do not know how to prevent that.
My .html file looks like this:
<div id="mycontainer" class="container">
<div class="map-container">
<div class="map-frame">
<div id="map" (click)="addMarker($event)"></div>
</div>
</div>
</div>
And my addMarker function looks like:
addMarker(event){
let latlng = this.map.mouseEventToLatLnt(event);
L.marker([latlng['lat'],latlng['lng']]).addTo(this.map);
}
I have tried checking if the mouseEvent movement attributes are different from 0, but it didnt have any effect. I also tried to use a Boolean which would be set to false on dragstart and to true dragend/dragleave/dragexit event of the map, but none of that worked as well.