diff --git a/apps/client/src/widgets/type_widgets/geo_map.ts b/apps/client/src/widgets/type_widgets/geo_map.ts index 06056bfab..20397089e 100644 --- a/apps/client/src/widgets/type_widgets/geo_map.ts +++ b/apps/client/src/widgets/type_widgets/geo_map.ts @@ -108,17 +108,12 @@ export default class GeoMapTypeWidget extends TypeWidget { type: "text" }); attributes.setLabel(note.noteId, "iconClass", CHILD_NOTE_ICON); - this.moveMarker(note.noteId, e.latlng); + // this.moveMarker(note.noteId, e.latlng); } this.#changeState(State.Normal); } - async moveMarker(noteId: string, latLng: LatLng | null) { - const value = latLng ? [latLng.lat, latLng.lng].join(",") : ""; - await attributes.setLabel(noteId, LOCATION_ATTRIBUTE, value); - } - async geoMapCreateChildNoteEvent({ ntxId }: EventData<"geoMapCreateChildNote">) { if (!this.isNoteContext(ntxId)) { return; @@ -179,7 +174,7 @@ export default class GeoMapTypeWidget extends TypeWidget { } deleteFromMapEvent({ noteId }: EventData<"deleteFromMap">) { - this.moveMarker(noteId, null); + // this.moveMarker(noteId, null); } buildTouchBarCommand({ TouchBar }: CommandListenerData<"buildTouchBar">) { diff --git a/apps/client/src/widgets/view_widgets/geo_view/editing.ts b/apps/client/src/widgets/view_widgets/geo_view/editing.ts new file mode 100644 index 000000000..863305ebc --- /dev/null +++ b/apps/client/src/widgets/view_widgets/geo_view/editing.ts @@ -0,0 +1,8 @@ +import { LatLng } from "leaflet"; +import attributes from "../../../services/attributes"; +import { LOCATION_ATTRIBUTE } from "./index.js"; + +export async function moveMarker(noteId: string, latLng: LatLng | null) { + const value = latLng ? [latLng.lat, latLng.lng].join(",") : ""; + await attributes.setLabel(noteId, LOCATION_ATTRIBUTE, value); +} diff --git a/apps/client/src/widgets/view_widgets/geo_view/index.ts b/apps/client/src/widgets/view_widgets/geo_view/index.ts index 6df005375..fb897b60e 100644 --- a/apps/client/src/widgets/view_widgets/geo_view/index.ts +++ b/apps/client/src/widgets/view_widgets/geo_view/index.ts @@ -87,7 +87,7 @@ interface MapData { const DEFAULT_COORDINATES: [number, number] = [3.878638227135724, 446.6630455551659]; const DEFAULT_ZOOM = 2; -const LOCATION_ATTRIBUTE = "geolocation"; +export const LOCATION_ATTRIBUTE = "geolocation"; const CHILD_NOTE_ICON = "bx bx-pin"; export default class GeoView extends ViewMode { diff --git a/apps/client/src/widgets/view_widgets/geo_view/markers.ts b/apps/client/src/widgets/view_widgets/geo_view/markers.ts index d7258610f..97f9dbcf3 100644 --- a/apps/client/src/widgets/view_widgets/geo_view/markers.ts +++ b/apps/client/src/widgets/view_widgets/geo_view/markers.ts @@ -1,10 +1,11 @@ import markerIcon from "leaflet/dist/images/marker-icon.png"; import markerIconShadow from "leaflet/dist/images/marker-shadow.png"; -import { marker, latLng, divIcon, Map } from "leaflet"; +import { marker, latLng, divIcon, Map, type Marker } from "leaflet"; import type FNote from "../../../entities/fnote.js"; import note_tooltip from "../../../services/note_tooltip.js"; import openContextMenu from "../../type_widgets/geo_map_context_menu.js"; import server from "../../../services/server.js"; +import { moveMarker } from "./editing.js"; let gpxLoaded = false; @@ -20,7 +21,7 @@ export default function processNoteWithMarker(map: Map, note: FNote, location: s }) .addTo(map) .on("moveend", (e) => { - // this.moveMarker(note.noteId, (e.target as Marker).getLatLng()); + moveMarker(note.noteId, (e.target as Marker).getLatLng()); }); newMarker.on("mousedown", ({ originalEvent }) => { // Middle click to open in new tab