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
feat(geomap): allow dragging
Elian Doran3281bb8e9f97
diff --git a/src/public/app/widgets/type_widgets/geo_map.ts b/src/public/app/widgets/type_widgets/geo_map.tsindex 99450f9ff4..67d41a53f2 100644--- a/src/public/app/widgets/type_widgets/geo_map.ts+++ b/src/public/app/widgets/type_widgets/geo_map.ts@@ -1,4 +1,4 @@-import type { LatLng, LeafletMouseEvent } from "leaflet";+import type { LatLng, LeafletMouseEvent, Marker } from "leaflet";import type FNote from "../../entities/fnote.js";import GeoMapWidget, { type InitCallback, type Leaflet } from "../geo_map.js";import TypeWidget from "./type_widget.js"@@ -116,9 +116,14 @@ export default class GeoMapTypeWidget extends TypeWidget {}const [ lat, lng ] = latLng.split(",", 2).map((el) => parseFloat(el));- L.marker(L.latLng(lat, lng))+ L.marker(L.latLng(lat, lng), {+ draggable: true+ }).addTo(map)- .bindPopup(childNote.title);+ .bindPopup(childNote.title)+ .on("moveend", e => {+ this.moveMarker(childNote.noteId, (e.target as Marker).getLatLng());+ });}}@@ -131,12 +136,15 @@ export default class GeoMapTypeWidget extends TypeWidget {return;}- const { noteId } = this.clipboard;- await attributes.setLabel(noteId, LOCATION_ATTRIBUTE, [e.latlng.lat, e.latlng.lng].join(","));+ this.moveMarker(this.clipboard.noteId, e.latlng);this.clipboard = undefined;this.#adjustCursor();}+ async moveMarker(noteId: string, latLng: LatLng) {+ await attributes.setLabel(noteId, LOCATION_ATTRIBUTE, [latLng.lat, latLng.lng].join(","));+ }+getData(): any {const map = this.geoMapWidget.map;if (!map) {