Fix Wereldexport world map loading and tiles.

Self-host Leaflet locally, proxy map tiles through cockpit, set explicit map height, and invalidate size after init.
This commit is contained in:
Aissa
2026-07-19 18:36:02 +00:00
parent 8712f503b1
commit 7289b770e5
15 changed files with 797 additions and 13 deletions
+15 -2
View File
@@ -160,6 +160,13 @@ window.ExportIntelMap = (function () {
});
}
function invalidateMapSize() {
if (!map) return;
map.invalidateSize(true);
setTimeout(function () { if (map) map.invalidateSize(true); }, 120);
setTimeout(function () { if (map) map.invalidateSize(true); }, 400);
}
function init(containerId) {
var el = document.getElementById(containerId);
if (!el || !window.L) return null;
@@ -169,9 +176,8 @@ window.ExportIntelMap = (function () {
clusterLayer = null;
}
map = L.map(containerId, { zoomControl: true, attributionControl: true }).setView([20, 10], 2);
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', {
L.tileLayer('/api/map/tiles/{z}/{x}/{y}.png', {
attribution: '© OSM © CARTO',
subdomains: 'abcd',
maxZoom: 19,
}).addTo(map);
@@ -207,6 +213,7 @@ window.ExportIntelMap = (function () {
wirePopup(root.querySelector('.leaflet-popup-content') || root);
});
invalidateMapSize();
return map;
}
@@ -234,6 +241,8 @@ window.ExportIntelMap = (function () {
if (clusterLayer.addLayers) clusterLayer.addLayers(markers);
else markers.forEach(function (m) { clusterLayer.addLayer(m); });
invalidateMapSize();
if (features.length === 1) {
var c = features[0].geometry.coordinates;
map.setView([c[1], c[0]], 10);
@@ -276,5 +285,9 @@ window.ExportIntelMap = (function () {
}
}
if (typeof window !== 'undefined') {
window.addEventListener('resize', function () { invalidateMapSize(); });
}
return { init, setFeatures, setOnEntityClick, setHalalMode, flyTo, closePopup, highlightEntity, destroy, TYPE_CFG: TYPE_CFG, cfg: cfg };
})();
+6
View File
@@ -25,6 +25,7 @@ function exportIntelApp() {
mapTypesSelected: [],
mapHalalMode: false,
mapHalalMin: 55,
mapError: '',
halalTopMarkets: [],
halalTopEntities: [],
listFocusId: null,
@@ -322,6 +323,11 @@ function exportIntelApp() {
var bundle = await fetch(url).then((r) => r.json());
this.halalTopMarkets = (bundle.meta && bundle.meta.top_markets) || [];
this.halalTopEntities = (bundle.meta && bundle.meta.top_halal_entities) || [];
if (!window.L || !window.ExportIntelMap) {
this.mapError = 'Kaart kon niet laden. Vernieuw de pagina (Ctrl+F5).';
return;
}
this.mapError = '';
if (window.ExportIntelMap) {
if (!document.getElementById('ei-map')) return;
var self = this;