fixed marker color when mission is running, saving new pos to mission when pos is amended

This commit is contained in:
PxlLoewe
2025-05-22 20:31:12 -07:00
parent 8c695ba990
commit b2890b3ecc
4 changed files with 103 additions and 57 deletions

View File

@@ -4,6 +4,7 @@ import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
import { useMapStore } from "_store/mapStore";
import { usePannelStore } from "_store/pannelStore";
import { MapPin, MapPinned, Radius, Ruler, Search, RulerDimensionLine, Scan } from "lucide-react";
import { getOsmAddress } from "querys/osm";
import { useEffect, useState } from "react";
import toast from "react-hot-toast";
import { Popup, useMap } from "react-leaflet";
@@ -100,43 +101,8 @@ export const ContextMenu = () => {
data-tip={einsatzBtnText}
style={{ transform: "translateX(-50%)" }}
onClick={async () => {
const address = await fetch(
`https://nominatim.openstreetmap.org/reverse?lat=${contextMenu.lat}&lon=${contextMenu.lng}&format=json`,
);
const data = (await address.json()) as {
address?: {
ISO3166_2_lvl4?: string;
country?: string;
country_code?: string;
county?: string;
house_number?: string;
municipality?: string;
postcode?: string;
road?: string;
state?: string;
city?: string;
town?: string;
};
display_name?: string;
importance?: number;
lat?: string;
licence?: string;
lon?: string;
name?: string;
osm_id?: number;
osm_type?: string;
place_id?: number;
place_rank?: number;
type?: string;
};
const addressObj = data.address ?? {};
const { parsed } = await getOsmAddress(contextMenu.lat, contextMenu.lng);
const objects = await addOSMobjects();
const exactAddress = objects.find((object) => {
return (
object.tags["addr:street"] == addressObj.road &&
object.tags["addr:housenumber"]?.includes(addressObj.house_number ?? "")
);
});
const closestToContext = objects.reduce((prev, curr) => {
const prevLat = prev.nodes?.[0]?.lat ?? 0;
const prevLon = prev.nodes?.[0]?.lon ?? 0;
@@ -160,11 +126,7 @@ export const ContextMenu = () => {
);
setMissionFormValues({
addressLat: contextMenu.lat,
addressLng: contextMenu.lng,
addressCity: addressObj.city || addressObj.town || "",
addressStreet: `${addressObj.road || "keine Straße"}, ${addressObj.house_number || "keine HN"}`,
addressZip: addressObj.postcode || "",
...parsed,
state: "draft",
addressOSMways: [closestToContext],
});