mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 07:45:51 +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"
|
type: "text"
|
||||||
});
|
});
|
||||||
attributes.setLabel(note.noteId, "iconClass", CHILD_NOTE_ICON);
|
attributes.setLabel(note.noteId, "iconClass", CHILD_NOTE_ICON);
|
||||||
this.moveMarker(note.noteId, e.latlng);
|
// this.moveMarker(note.noteId, e.latlng);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#changeState(State.Normal);
|
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">) {
|
async geoMapCreateChildNoteEvent({ ntxId }: EventData<"geoMapCreateChildNote">) {
|
||||||
if (!this.isNoteContext(ntxId)) {
|
if (!this.isNoteContext(ntxId)) {
|
||||||
return;
|
return;
|
||||||
@@ -179,7 +174,7 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteFromMapEvent({ noteId }: EventData<"deleteFromMap">) {
|
deleteFromMapEvent({ noteId }: EventData<"deleteFromMap">) {
|
||||||
this.moveMarker(noteId, null);
|
// this.moveMarker(noteId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTouchBarCommand({ TouchBar }: CommandListenerData<"buildTouchBar">) {
|
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_COORDINATES: [number, number] = [3.878638227135724, 446.6630455551659];
|
||||||
const DEFAULT_ZOOM = 2;
|
const DEFAULT_ZOOM = 2;
|
||||||
const LOCATION_ATTRIBUTE = "geolocation";
|
export const LOCATION_ATTRIBUTE = "geolocation";
|
||||||
const CHILD_NOTE_ICON = "bx bx-pin";
|
const CHILD_NOTE_ICON = "bx bx-pin";
|
||||||
|
|
||||||
export default class GeoView extends ViewMode<MapData> {
|
export default class GeoView extends ViewMode<MapData> {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import markerIcon from "leaflet/dist/images/marker-icon.png";
|
import markerIcon from "leaflet/dist/images/marker-icon.png";
|
||||||
import markerIconShadow from "leaflet/dist/images/marker-shadow.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 type FNote from "../../../entities/fnote.js";
|
||||||
import note_tooltip from "../../../services/note_tooltip.js";
|
import note_tooltip from "../../../services/note_tooltip.js";
|
||||||
import openContextMenu from "../../type_widgets/geo_map_context_menu.js";
|
import openContextMenu from "../../type_widgets/geo_map_context_menu.js";
|
||||||
import server from "../../../services/server.js";
|
import server from "../../../services/server.js";
|
||||||
|
import { moveMarker } from "./editing.js";
|
||||||
|
|
||||||
let gpxLoaded = false;
|
let gpxLoaded = false;
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ export default function processNoteWithMarker(map: Map, note: FNote, location: s
|
|||||||
})
|
})
|
||||||
.addTo(map)
|
.addTo(map)
|
||||||
.on("moveend", (e) => {
|
.on("moveend", (e) => {
|
||||||
// this.moveMarker(note.noteId, (e.target as Marker).getLatLng());
|
moveMarker(note.noteId, (e.target as Marker).getLatLng());
|
||||||
});
|
});
|
||||||
newMarker.on("mousedown", ({ originalEvent }) => {
|
newMarker.on("mousedown", ({ originalEvent }) => {
|
||||||
// Middle click to open in new tab
|
// Middle click to open in new tab
|
||||||
|
|||||||
Reference in New Issue
Block a user