mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 15:49:00 +02:00
refactor(views/geo): remove dependency to leaflet in map layer
This commit is contained in:
parent
bea40d4c2f
commit
180841f364
@ -10,8 +10,8 @@ import toast from "../../../services/toast.js";
|
|||||||
import { CommandListenerData, EventData } from "../../../components/app_context.js";
|
import { CommandListenerData, EventData } from "../../../components/app_context.js";
|
||||||
import { createNewNote, moveMarker, setupDragging } from "./editing.js";
|
import { createNewNote, moveMarker, setupDragging } from "./editing.js";
|
||||||
import { openMapContextMenu } from "./context_menu.js";
|
import { openMapContextMenu } from "./context_menu.js";
|
||||||
import getMapLayer from "./map_layer.js";
|
|
||||||
import attributes from "../../../services/attributes.js";
|
import attributes from "../../../services/attributes.js";
|
||||||
|
import { MAP_LAYERS } from "./map_layer.js";
|
||||||
|
|
||||||
const TPL = /*html*/`
|
const TPL = /*html*/`
|
||||||
<div class="geo-view">
|
<div class="geo-view">
|
||||||
@ -337,3 +337,21 @@ export default class GeoView extends ViewMode<MapData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getMapLayer(layerName: string) {
|
||||||
|
const layer = MAP_LAYERS[layerName] ?? MAP_LAYERS["openstreetmap"];
|
||||||
|
|
||||||
|
if (layer.type === "vector") {
|
||||||
|
const style = (typeof layer.style === "string" ? layer.style : await layer.style());
|
||||||
|
await import("@maplibre/maplibre-gl-leaflet");
|
||||||
|
|
||||||
|
return L.maplibreGL({
|
||||||
|
style: style as any
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return L.tileLayer(layer.url, {
|
||||||
|
attribution: layer.attribution,
|
||||||
|
detectRetina: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import L from "leaflet";
|
|
||||||
|
|
||||||
interface Layer {
|
interface Layer {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
@ -54,20 +52,3 @@ export const MAP_LAYERS: Record<string, VectorLayer | RasterLayer> = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default async function getMapLayer(layerName: string) {
|
|
||||||
const layer = MAP_LAYERS[layerName] ?? MAP_LAYERS["openstreetmap"];
|
|
||||||
|
|
||||||
if (layer.type === "vector") {
|
|
||||||
const style = (typeof layer.style === "string" ? layer.style : await layer.style());
|
|
||||||
await import("@maplibre/maplibre-gl-leaflet");
|
|
||||||
|
|
||||||
return L.maplibreGL({
|
|
||||||
style: style as any
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return L.tileLayer(layer.url, {
|
|
||||||
attribution: layer.attribution,
|
|
||||||
detectRetina: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user