mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
feat(geomap): save & restore zoom
This commit is contained in:
parent
f66f437c8e
commit
4d5e04fc5a
@ -7,7 +7,8 @@ const TPL = `<div class="note-detail-geo-map note-detail-printable"></div>`;
|
|||||||
|
|
||||||
interface MapData {
|
interface MapData {
|
||||||
view?: {
|
view?: {
|
||||||
center: LatLng | [ number, number ];
|
center?: LatLng | [ number, number ];
|
||||||
|
zoom?: number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,11 +47,14 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
if (blob) {
|
if (blob) {
|
||||||
parsedContent = JSON.parse(blob.content);
|
parsedContent = JSON.parse(blob.content);
|
||||||
}
|
}
|
||||||
console.log(parsedContent);
|
|
||||||
const center = parsedContent.view?.center ?? [51.505, -0.09];
|
|
||||||
|
|
||||||
map.setView(center, 13);
|
const center = parsedContent.view?.center ?? [51.505, -0.09];
|
||||||
map.on("moveend", () => this.spacedUpdate.scheduleUpdate());
|
const zoom = parsedContent.view?.zoom ?? 13;
|
||||||
|
map.setView(center, zoom);
|
||||||
|
|
||||||
|
const updateFn = () => this.spacedUpdate.scheduleUpdate();
|
||||||
|
map.on("moveend", updateFn);
|
||||||
|
map.on("zoomend", updateFn);
|
||||||
}
|
}
|
||||||
|
|
||||||
getData(): any {
|
getData(): any {
|
||||||
@ -61,7 +65,8 @@ export default class GeoMapTypeWidget extends TypeWidget {
|
|||||||
|
|
||||||
const data: MapData = {
|
const data: MapData = {
|
||||||
view: {
|
view: {
|
||||||
center: map.getBounds().getCenter()
|
center: map.getBounds().getCenter(),
|
||||||
|
zoom: map.getZoom()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user