chore(views/geomap): reintroduce moving markers

This commit is contained in:
Elian Doran
2025-07-06 12:22:51 +03:00
parent 579a261612
commit 939e99637f
4 changed files with 14 additions and 10 deletions

View File

@@ -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">) {

View 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);
}

View File

@@ -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> {

View File

@@ -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