mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
chore(views/geomap): reintroduce moving markers
This commit is contained in:
@@ -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">) {
|
||||
|
||||
8
apps/client/src/widgets/view_widgets/geo_view/editing.ts
Normal file
8
apps/client/src/widgets/view_widgets/geo_view/editing.ts
Normal file
@@ -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);
|
||||
}
|
||||
@@ -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> {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user