Usability of adding a new point: if not zoomed in sufficiently, the map will zoom to the new-location marker
This commit is contained in:
parent
4790a10cb6
commit
f4ea36de9a
1 changed files with 10 additions and 1 deletions
|
@ -5,6 +5,7 @@ import Img from "../../UI/Base/Img";
|
||||||
import ScrollableFullScreen from "../../UI/Base/ScrollableFullScreen";
|
import ScrollableFullScreen from "../../UI/Base/ScrollableFullScreen";
|
||||||
import AddNewMarker from "../../UI/BigComponents/AddNewMarker";
|
import AddNewMarker from "../../UI/BigComponents/AddNewMarker";
|
||||||
import FilteredLayer from "../../Models/FilteredLayer";
|
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.
|
* 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);
|
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({
|
icon: L.divIcon({
|
||||||
html: new AddNewMarker(filteredLayers).ConstructElement(),
|
html: new AddNewMarker(filteredLayers).ConstructElement(),
|
||||||
iconSize: [50, 50],
|
iconSize: [50, 50],
|
||||||
|
@ -59,6 +61,13 @@ export default class StrayClickHandler {
|
||||||
self._lastMarker.bindPopup(popup);
|
self._lastMarker.bindPopup(popup);
|
||||||
|
|
||||||
self._lastMarker.on("click", () => {
|
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.AttachTo("strayclick")
|
||||||
uiToShow.Activate();
|
uiToShow.Activate();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue