Skip to content

Commit

Permalink
fix accidental removal of line creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Freddy Järvå committed Apr 25, 2021
1 parent bfeec98 commit 90baafa
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/map/Leaflet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,22 @@
}
function onEntranceClick(e: L.LeafletMouseEvent) {
if (e.originalEvent.button === 2) {
if (e.originalEvent.button === 0) {
// 0 = Left Mouse
if (dragStart !== null && dragStart.node.getLatLng() !== e.latlng) {
let line = lineBetween(dragStart.node.getLatLng(), e.latlng);
line
.on("click", (e) => {
line.remove();
})
.addTo(map);
// Super ugly way to make sure popup doesn't open when clicking on endpoint for the line
setTimeout(() => {
coordinateToMarkers.get(latLngToKey(e.latlng)).node.closePopup();
}, 100);
}
} else if (e.originalEvent.button === 2) {
// Right mouse
toggleMarker(e);
}
Expand Down

0 comments on commit 90baafa

Please sign in to comment.