Files
Trilium/apps/client/src/widgets/view_widgets/geo_view/index.ts

57 lines
1.3 KiB
TypeScript
Raw Normal View History

import ViewMode, { ViewModeArgs } from "../view_mode.js";
import L from "leaflet";
const TPL = /*html*/`
<div class="geo-view">
2025-07-06 11:15:28 +03:00
<style>
.geo-view {
overflow: hidden;
position: relative;
height: 100%;
}
.geo-map-container {
height: 100%;
overflow: hidden;
}
2025-07-06 11:15:28 +03:00
</style>
<div class="geo-map-container"></div>
</div>`;
export default class GeoView extends ViewMode<{}> {
private $root: JQuery<HTMLElement>;
private $container!: JQuery<HTMLElement>;
private map?: L.Map;
constructor(args: ViewModeArgs) {
super(args, "geoMap");
this.$root = $(TPL);
this.$container = this.$root.find(".geo-map-container");
args.$parent.append(this.$root);
}
async renderList() {
this.renderMap();
return this.$root;
}
async renderMap() {
const map = L.map(this.$container[0], {
worldCopyJump: true
});
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
detectRetina: true
}).addTo(map);
this.map = map;
}
2025-07-06 11:15:28 +03:00
get isFullHeight(): boolean {
return true;
}
}