From f4ea36de9a577ca332e4166fd682cc367d28a3ef Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sun, 22 Aug 2021 20:23:13 +0200 Subject: [PATCH] Usability of adding a new point: if not zoomed in sufficiently, the map will zoom to the new-location marker --- Logic/Actors/StrayClickHandler.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Logic/Actors/StrayClickHandler.ts b/Logic/Actors/StrayClickHandler.ts index f42ef80f1..3a7adfa34 100644 --- a/Logic/Actors/StrayClickHandler.ts +++ b/Logic/Actors/StrayClickHandler.ts @@ -5,6 +5,7 @@ import Img from "../../UI/Base/Img"; import ScrollableFullScreen from "../../UI/Base/ScrollableFullScreen"; import AddNewMarker from "../../UI/BigComponents/AddNewMarker"; import FilteredLayer from "../../Models/FilteredLayer"; +import Constants from "../../Models/Constants"; /** * The stray-click-hanlders adds a marker to the map if no feature was clicked. @@ -41,7 +42,8 @@ export default class StrayClickHandler { } selectedElement.setData(undefined); - self._lastMarker = L.marker([lastClick.lat, lastClick.lon], { + const clickCoor : [number, number] = [lastClick.lat, lastClick.lon] + self._lastMarker = L.marker(clickCoor, { icon: L.divIcon({ html: new AddNewMarker(filteredLayers).ConstructElement(), iconSize: [50, 50], @@ -59,6 +61,13 @@ export default class StrayClickHandler { self._lastMarker.bindPopup(popup); self._lastMarker.on("click", () => { + if(leafletMap.data.getZoom() < Constants.userJourney.minZoomLevelToAddNewPoints){ + self._lastMarker.closePopup() + leafletMap.data.flyTo(clickCoor, Constants.userJourney.minZoomLevelToAddNewPoints) + return; + } + + uiToShow.AttachTo("strayclick") uiToShow.Activate(); });