Koordinaten kopieren
This commit is contained in:
@@ -13,9 +13,22 @@ const centerHereCallback = (e, map) => {
|
||||
centerHere(e, map);
|
||||
};
|
||||
|
||||
// Hilfsfunktion zur Umwandlung in das DMS-Format
|
||||
const toDMS = (decimal, isLat) => {
|
||||
const direction = decimal >= 0 ? (isLat ? "N" : "E") : isLat ? "S" : "W";
|
||||
const absDecimal = Math.abs(decimal);
|
||||
const degrees = Math.floor(absDecimal);
|
||||
const minutesDecimal = (absDecimal - degrees) * 60;
|
||||
const minutes = Math.floor(minutesDecimal);
|
||||
const seconds = ((minutesDecimal - minutes) * 60).toFixed(1);
|
||||
return `${degrees}°${minutes}'${seconds}"${direction}`;
|
||||
};
|
||||
|
||||
// Funktion zum Anzeigen und Kopieren der Koordinaten
|
||||
const showCoordinates = (e) => {
|
||||
const coordinates = `Breitengrad: ${e.latlng.lat.toFixed(5)}, Längengrad: ${e.latlng.lng.toFixed(5)}`;
|
||||
const latDMS = toDMS(e.latlng.lat, true);
|
||||
const lngDMS = toDMS(e.latlng.lng, false);
|
||||
const coordinates = `${latDMS} ${lngDMS}`;
|
||||
|
||||
// Überprüfen, ob das Clipboard-API unterstützt wird
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
@@ -109,7 +122,10 @@ export const addItemsToMapContextMenu = (map, menuItemAdded, setMenuItemAdded, h
|
||||
map.contextmenu.removeAllItems();
|
||||
|
||||
// Koordinaten dynamisch anzeigen
|
||||
const coordinates = `Lat: ${e.latlng.lat.toFixed(5)}, Lng: ${e.latlng.lng.toFixed(5)}`;
|
||||
const latDMS = toDMS(e.latlng.lat, true);
|
||||
const lngDMS = toDMS(e.latlng.lng, false);
|
||||
const coordinates = `${latDMS} ${lngDMS}`;
|
||||
|
||||
map.contextmenu.addItem({
|
||||
text: coordinates,
|
||||
icon: "img/not_listed_location.png",
|
||||
|
||||
Reference in New Issue
Block a user