feat: paste centerHere function into zoomAndCenterUtil.js with error

This commit is contained in:
ISA
2024-07-12 07:03:37 +02:00
parent 91923ef8b4
commit 042d086a49
2 changed files with 60 additions and 9 deletions

View File

@@ -0,0 +1,31 @@
// utils/zoomAndCenterUtils.js
export const zoomIn = (e, map) => {
if (!map) {
console.error("map is not defined in zoomIn");
return;
}
map.flyTo(e.latlng, 12);
localStorage.setItem("mapZoom", map.getZoom());
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
};
export const zoomOut = (map) => {
if (!map) {
console.error("map is not defined in zoomOut");
return;
}
const x = 51.41321407879154;
const y = 7.739617925303934;
const zoom = 7;
map.flyTo([x, y], zoom);
localStorage.setItem("mapZoom", map.getZoom());
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
};
export const centerHere = (e, map) => {
if (!map) {
console.error("map is not defined in centerHere");
return;
}
map.panTo(e.latlng);
};