Rein- und rauszoomen sowie Hier Zentrieren funktion implementieren in Kontxtmenü

This commit is contained in:
ISA
2024-04-15 12:22:37 +02:00
parent 2ff0fde192
commit a6d8c72d17
13 changed files with 103 additions and 34 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -153,7 +153,7 @@
/******/ /******/
/******/ /* webpack/runtime/getFullHash */ /******/ /* webpack/runtime/getFullHash */
/******/ !function() { /******/ !function() {
/******/ __webpack_require__.h = function() { return "a77be7ddd2f59b1f"; } /******/ __webpack_require__.h = function() { return "140b462da8270237"; }
/******/ }(); /******/ }();
/******/ /******/
/******/ /* webpack/runtime/global */ /******/ /* webpack/runtime/global */

File diff suppressed because one or more lines are too long

View File

@@ -40,8 +40,6 @@ const MapComponent = () => {
{ text: "Hier zentrieren", callback: centerHere }, { text: "Hier zentrieren", callback: centerHere },
], ],
}); });
initialMap.flyTo([53.34399291274182, 7.607860512806846], 12);
console.log(initialMap); console.log(initialMap);
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: attribution:
@@ -53,9 +51,6 @@ const MapComponent = () => {
}, [mapRef, map]); }, [mapRef, map]);
console.log(map); console.log(map);
if (map) {
map.flyTo([53.34399291274182, 7.607860512806846], 18);
}
//-----Kontextmenu---------------- //-----Kontextmenu----------------
const newLink = (e) => { const newLink = (e) => {
try { try {
@@ -83,32 +78,14 @@ const MapComponent = () => {
}; };
const zoomIn = (e) => { const zoomIn = (e) => {
console.log(e); initialMap.flyTo(e.latlng, 12);
console.log(initialMap);
console.log("zoomIn");
/* if (!map) {
console.error("Karte ist noch nicht initialisiert in zoomIn.");
return;
} */
initialMap.flyTo(
{
lat: 53.34399291274182,
lng: 7.607860512806846,
},
12
);
}; };
const zoomOut = (e) => { const zoomOut = (e) => {
if (!map) { fly();
console.error("Karte ist noch nicht initialisiert in zoomOut."); };
return; const centerHere = (e) => {
} initialMap.panTo(e.latlng);
// Annahme: Du willst beim Rauszoomen die aktuelle Position halten
// und nur den Zoom-Level ändern. Hier reduzieren wir den Zoom-Level um 1.
const currentZoom = map.getZoom();
map.flyTo(e.latlng, map.getZoom() - 1);
}; };
const showCoordinates = (e) => { const showCoordinates = (e) => {
@@ -156,9 +133,40 @@ const MapComponent = () => {
.openOn(e.relatedTarget); .openOn(e.relatedTarget);
}; };
const centerHere = (e) => { function fly(stationValue) {
map.panTo(e.latlng); var x = 51.41321407879154;
}; var y = 7.739617925303934;
var zoom = 7;
/* for (var i = 0; i < dataStaticlength; i++) {
var gisStatics = dataStatic[i];
if (stationValue === gisStatics.Area_Name) {
//console.log(gisStatics.X+","+gisStatics.Y);
x = gisStatics.X;
y = gisStatics.Y;
}
}
if (y === 7.739617925303934) {
zoom = 8;
} */
initialMap.flyTo([x, y], zoom);
/* var popup = new L.Popup();
oms.addListener("click", function (marker) {
popup.setContent(marker.desc);
popup.setLatLng(marker.getLatLng());
map.openPopup(popup);
});
for (var i = 0; i < window.mapData.length; i++) {
var datum = window.mapData[i];
var loc = new L.LatLng(datum.lat, datum.lon);
var marker = new L.Marker(loc);
marker.desc = datum.d;
map.addLayer(marker);
//oms.addMarker(marker); // <-- here
} */
}
return ( return (
<div <div