Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(views/geomap): reintroduce moving markers
Elian Doran939e99637f7b
diff --git a/apps/client/src/widgets/type_widgets/geo_map.ts b/apps/client/src/widgets/type_widgets/geo_map.tsindex 06056bfab1..20397089ec 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.tsnew file mode 100644index 0000000000..863305ebc4--- /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.tsindex 6df005375a..fb897b60ed 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<MapData> {diff --git a/apps/client/src/widgets/view_widgets/geo_view/markers.ts b/apps/client/src/widgets/view_widgets/geo_view/markers.tsindex d7258610f0..97f9dbcf3b 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