fix (map): map loading issues

when trying to load a shp file, it would load indefinitly with window.L
being undefined
This commit is contained in:
MickaelK 2025-09-23 14:11:57 +10:00
parent 6299f8776f
commit aed8712fd7

View file

@ -26,7 +26,6 @@ export default async function(render, { mime, getDownloadUrl = nop, getFilename
qs($page, "component-menubar"), qs($page, "component-menubar"),
buttonDownload(getFilename(), getDownloadUrl()), buttonDownload(getFilename(), getDownloadUrl()),
); );
const map = window.L.map("map"); const map = window.L.map("map");
const removeLoader = createLoader(qs($page, "#map")); const removeLoader = createLoader(qs($page, "#map"));
await effect(ajax({ url: getDownloadUrl(), responseType: "arraybuffer" }).pipe( await effect(ajax({ url: getDownloadUrl(), responseType: "arraybuffer" }).pipe(
@ -51,11 +50,11 @@ export default async function(render, { mime, getDownloadUrl = nop, getFilename
} }
export async function init($root) { export async function init($root) {
const priors = ($root && [ const priors = $root ? [
$root.classList.add("component_page_viewerpage"), $root.classList.add("component_page_viewerpage"),
loadCSS(import.meta.url, "./component_menubar.css"), loadCSS(import.meta.url, "./component_menubar.css"),
loadCSS(import.meta.url, "../ctrl_viewerpage.css"), loadCSS(import.meta.url, "../ctrl_viewerpage.css"),
]); ] : [];
await Promise.all([ await Promise.all([
loadJS(import.meta.url, "../../lib/vendor/leaflet/leaflet.js"), loadJS(import.meta.url, "../../lib/vendor/leaflet/leaflet.js"),
loadCSS(import.meta.url, "../../lib/vendor/leaflet/leaflet.css"), loadCSS(import.meta.url, "../../lib/vendor/leaflet/leaflet.css"),