mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 02:02:29 +08:00
feat(geomap): set location after creating a note
This commit is contained in:
parent
2582924046
commit
a3f257f3c5
@ -1,4 +1,4 @@
|
||||
import type { LatLng } from "leaflet";
|
||||
import type { LatLng, LeafletMouseEvent } from "leaflet";
|
||||
import type FNote from "../../entities/fnote.js";
|
||||
import GeoMapWidget from "../geo_map.js";
|
||||
import TypeWidget from "./type_widget.js"
|
||||
@ -7,6 +7,7 @@ import toastService from "../../services/toast.js";
|
||||
import dialogService from "../../services/dialog.js";
|
||||
import type { EventData } from "../../components/app_context.js";
|
||||
import { t } from "../../services/i18n.js";
|
||||
import attributes from "../../services/attributes.js";
|
||||
|
||||
const TPL = `\
|
||||
<div class="note-detail-geo-map note-detail-printable">
|
||||
@ -17,6 +18,8 @@ const TPL = `\
|
||||
</style>
|
||||
</div>`;
|
||||
|
||||
const LOCATION_ATTRIBUTE = "latLng";
|
||||
|
||||
interface MapData {
|
||||
view?: {
|
||||
center?: LatLng | [ number, number ];
|
||||
@ -80,6 +83,16 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
||||
const updateFn = () => this.spacedUpdate.scheduleUpdate();
|
||||
map.on("moveend", updateFn);
|
||||
map.on("zoomend", updateFn);
|
||||
map.on("click", (e) => this.#onMapClicked(e));
|
||||
}
|
||||
|
||||
async #onMapClicked(e: LeafletMouseEvent) {
|
||||
if (!this.clipboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { noteId } = this.clipboard;
|
||||
await attributes.setLabel(noteId, LOCATION_ATTRIBUTE, [e.latlng.lat, e.latlng.lng].join(","));
|
||||
}
|
||||
|
||||
getData(): any {
|
||||
|
Loading…
x
Reference in New Issue
Block a user