From fed0598b47c63a0c717459d707239a2fe4c652f1 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 21 Jan 2025 13:46:18 +0200 Subject: [PATCH] feat(geomap): adjust cursor when adding new note --- src/public/app/widgets/geo_map.ts | 5 +++-- src/public/app/widgets/type_widgets/geo_map.ts | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/public/app/widgets/geo_map.ts b/src/public/app/widgets/geo_map.ts index d49f1c1d3..46fb2e414 100644 --- a/src/public/app/widgets/geo_map.ts +++ b/src/public/app/widgets/geo_map.ts @@ -22,6 +22,7 @@ export type InitCallback = ((L: Leaflet) => void); export default class GeoMapWidget extends NoteContextAwareWidget { map?: Map; + $container!: JQuery; private initCallback?: InitCallback; constructor(widgetMode: "type", initCallback?: InitCallback) { @@ -32,13 +33,13 @@ export default class GeoMapWidget extends NoteContextAwareWidget { doRender() { this.$widget = $(TPL); - const $container = this.$widget.find(".geo-map-container"); + this.$container = this.$widget.find(".geo-map-container"); library_loader.requireLibrary(library_loader.LEAFLET) .then(async () => { const L = (await import("leaflet")).default; - const map = L.map($container[0], { + const map = L.map(this.$container[0], { }); diff --git a/src/public/app/widgets/type_widgets/geo_map.ts b/src/public/app/widgets/type_widgets/geo_map.ts index 3bb69da07..99450f9ff 100644 --- a/src/public/app/widgets/type_widgets/geo_map.ts +++ b/src/public/app/widgets/type_widgets/geo_map.ts @@ -15,6 +15,10 @@ const TPL = `\ .leaflet-pane { z-index: 1; } + + .geo-map-container.placing-note { + cursor: crosshair; + } `; @@ -118,6 +122,10 @@ export default class GeoMapTypeWidget extends TypeWidget { } } + #adjustCursor() { + this.geoMapWidget.$container.toggleClass("placing-note", !!this.clipboard); + } + async #onMapClicked(e: LeafletMouseEvent) { if (!this.clipboard) { return; @@ -126,6 +134,7 @@ export default class GeoMapTypeWidget extends TypeWidget { const { noteId } = this.clipboard; await attributes.setLabel(noteId, LOCATION_ATTRIBUTE, [e.latlng.lat, e.latlng.lng].join(",")); this.clipboard = undefined; + this.#adjustCursor(); } getData(): any { @@ -166,6 +175,7 @@ export default class GeoMapTypeWidget extends TypeWidget { toastService.showMessage(t("relation_map.click_on_canvas_to_place_new_note")); this.clipboard = { noteId: note.noteId, title }; + this.#adjustCursor(); } async doRefresh(note: FNote) {