feat: dynamische ev.local und URL für Karte, Karte ist lokal zugreifen ohne IP zu ändern auf verschiedene Server
This commit is contained in:
@@ -3,6 +3,49 @@ import { addContextMenuToMarker } from "../../utils/addContextMenuToMarker";
|
||||
import { addItemsToMapContextMenu } from "../../components/useMapContextMenu"; // Importiere die Funktion
|
||||
|
||||
const useGmaMarkersLayer = (map, markers, GisStationsMeasurements, GMA, oms, isVisible) => {
|
||||
const zoomIn = (e, map) => {
|
||||
if (!map) {
|
||||
console.error("map is not defined in zoomIn");
|
||||
return;
|
||||
}
|
||||
|
||||
const currentZoom = map.getZoom();
|
||||
|
||||
if (currentZoom < 14) {
|
||||
map.flyTo(e.latlng, 14);
|
||||
localStorage.setItem("mapZoom", 16);
|
||||
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
|
||||
}
|
||||
};
|
||||
|
||||
const zoomOut = (map) => {
|
||||
if (!map) {
|
||||
console.error("map is not defined in zoomOut");
|
||||
return;
|
||||
}
|
||||
|
||||
const currentZoom = map.getZoom();
|
||||
|
||||
if (currentZoom > 7) {
|
||||
const x = 51.41321407879154;
|
||||
const y = 7.739617925303934;
|
||||
const zoom = 7;
|
||||
|
||||
map.flyTo([x, y], zoom);
|
||||
localStorage.setItem("mapZoom", zoom);
|
||||
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
|
||||
}
|
||||
};
|
||||
|
||||
const centerHere = (e, map) => {
|
||||
if (!map) {
|
||||
console.error("map is not defined in centerHere");
|
||||
return;
|
||||
}
|
||||
map.panTo(e.latlng);
|
||||
localStorage.setItem("mapZoom", map.getZoom());
|
||||
localStorage.setItem("mapCenter", JSON.stringify(map.getCenter()));
|
||||
};
|
||||
const protocol = window.location.protocol; // Holt das Protokoll (z.B. http oder https)
|
||||
const hostname = window.location.hostname; // Holt den Hostnamen (z.B. 10.10.0.70)
|
||||
const baseUrl = `${protocol}//${hostname}/talas5/devices/`; // Basis-URL zusammenstellen
|
||||
@@ -64,6 +107,7 @@ const useGmaMarkersLayer = (map, markers, GisStationsMeasurements, GMA, oms, isV
|
||||
event.preventDefault();
|
||||
console.log("Rechtsklick auf Tooltip erkannt");
|
||||
|
||||
// Kombiniere die Kontextmenü-Items
|
||||
// Kombiniere die Kontextmenü-Items
|
||||
const combinedContextMenuItems = [
|
||||
{
|
||||
@@ -80,32 +124,34 @@ const useGmaMarkersLayer = (map, markers, GisStationsMeasurements, GMA, oms, isV
|
||||
},
|
||||
},
|
||||
{ separator: true },
|
||||
// Füge zusätzliche Items hinzu
|
||||
...[
|
||||
{
|
||||
text: "Koordinaten anzeigen",
|
||||
icon: "/img/not_listed_location.png",
|
||||
callback: (e) => {
|
||||
alert("Breitengrad: " + e.latlng.lat.toFixed(5) + "\nLängengrad: " + e.latlng.lng.toFixed(5));
|
||||
},
|
||||
//Koordinaten anzeigen auf den gesamte Tooltip fläche ist ein Wert, deswegen ausgeblendet
|
||||
/* {
|
||||
text: "Koordinaten anzeigen",
|
||||
icon: "/img/not_listed_location.png",
|
||||
callback: () => {
|
||||
const latlng = marker.getLatLng(); // Hole die Koordinaten direkt vom Marker
|
||||
alert("Breitengrad: " + latlng.lat.toFixed(5) + "\nLängengrad: " + latlng.lng.toFixed(5));
|
||||
},
|
||||
{ separator: true },
|
||||
{
|
||||
text: "Reinzoomen",
|
||||
icon: "img/zoom_in.png",
|
||||
callback: () => map.zoomIn(),
|
||||
}, */
|
||||
{ separator: true },
|
||||
{
|
||||
text: "Reinzoomen",
|
||||
icon: "img/zoom_in.png",
|
||||
callback: () => zoomIn(map),
|
||||
},
|
||||
{
|
||||
text: "Rauszoomen",
|
||||
icon: "img/zoom_out.png",
|
||||
callback: () => zoomOut(map),
|
||||
},
|
||||
{
|
||||
text: "Hier zentrieren",
|
||||
icon: "img/center_focus.png",
|
||||
callback: () => {
|
||||
const latlng = marker.getLatLng(); // Hole die Koordinaten direkt vom Marker
|
||||
centerHere({ latlng }, map);
|
||||
},
|
||||
{
|
||||
text: "Rauszoomen",
|
||||
icon: "img/zoom_out.png",
|
||||
callback: () => map.zoomOut(),
|
||||
},
|
||||
{
|
||||
text: "Hier zentrieren",
|
||||
icon: "img/center_focus.png",
|
||||
callback: (e) => map.panTo(e.latlng),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
// Benutzerdefiniertes Kontextmenü anzeigen
|
||||
|
||||
Reference in New Issue
Block a user