Adjust zoom conditions: zoomIn only if zoom < 14, zoomOut only if zoom > 7
This commit is contained in:
@@ -14,9 +14,14 @@ export const zoomIn = (e, map) => {
|
|||||||
console.error("map is not defined in zoomIn");
|
console.error("map is not defined in zoomIn");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
map.flyTo(e.latlng, 12);
|
|
||||||
localStorage.setItem("mapZoom", map.getZoom());
|
const currentZoom = map.getZoom();
|
||||||
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
|
|
||||||
|
if (currentZoom < 14) {
|
||||||
|
map.flyTo(e.latlng, 14);
|
||||||
|
localStorage.setItem("mapZoom", 16);
|
||||||
|
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const zoomOut = (map) => {
|
export const zoomOut = (map) => {
|
||||||
@@ -24,14 +29,18 @@ export const zoomOut = (map) => {
|
|||||||
console.error("map is not defined in zoomOut");
|
console.error("map is not defined in zoomOut");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const x = 51.41321407879154;
|
|
||||||
const y = 7.739617925303934;
|
const currentZoom = map.getZoom();
|
||||||
const zoom = 7;
|
|
||||||
//console.log("map");
|
if (currentZoom > 7) {
|
||||||
//console.log(map);
|
const x = 51.41321407879154;
|
||||||
map.flyTo([x, y], zoom);
|
const y = 7.739617925303934;
|
||||||
localStorage.setItem("mapZoom", map.getZoom());
|
const zoom = 7;
|
||||||
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
|
|
||||||
|
map.flyTo([x, y], zoom);
|
||||||
|
localStorage.setItem("mapZoom", zoom);
|
||||||
|
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const centerHere = (e, map) => {
|
export const centerHere = (e, map) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user