Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(views/geo): remove dependency to leaflet in map layer
Elian Doran180841f3640e
diff --git a/apps/client/src/widgets/view_widgets/geo_view/index.ts b/apps/client/src/widgets/view_widgets/geo_view/index.tsindex 5987e96e74..040e37e18d 100644--- a/apps/client/src/widgets/view_widgets/geo_view/index.ts+++ b/apps/client/src/widgets/view_widgets/geo_view/index.ts@@ -10,8 +10,8 @@ import toast from "../../../services/toast.js";import { CommandListenerData, EventData } from "../../../components/app_context.js";import { createNewNote, moveMarker, setupDragging } from "./editing.js";import { openMapContextMenu } from "./context_menu.js";-import getMapLayer from "./map_layer.js";import attributes from "../../../services/attributes.js";+import { MAP_LAYERS } from "./map_layer.js";const TPL = /*html*/`<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+ });+}diff --git a/apps/client/src/widgets/view_widgets/geo_view/map_layer.ts b/apps/client/src/widgets/view_widgets/geo_view/map_layer.tsindex a88344cf5b..422f1d6133 100644--- a/apps/client/src/widgets/view_widgets/geo_view/map_layer.ts+++ b/apps/client/src/widgets/view_widgets/geo_view/map_layer.ts@@ -1,5 +1,3 @@-import L from "leaflet";-interface Layer {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- });-}