diff --git a/public/nodes.js b/public/nodes.js index 7fc3a699..87acfc3b 100644 --- a/public/nodes.js +++ b/public/nodes.js @@ -74,6 +74,29 @@ let wsHandler = null; let detailMap = null; + // #1461 followup: node-detail inset map tile layer that honors the + // customizer dark-tile-provider pick (#1420/#1430). Falls back to + // window.getTileUrl() output if the registry isn't loaded. Also applies + // the provider's invert CSS filter to the tile pane when needed. + function _applyTilesToNodeMap(map) { + if (!map) return; + var tileUrl = (window.getTileUrl && window.getTileUrl()) || 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; + var provider = window.getActiveTileProvider && window.getActiveTileProvider(); + var attribution = (provider && provider.attribution) || '© OpenStreetMap contributors'; + var layer = L.tileLayer(tileUrl, { maxZoom: 18, attribution: attribution }).addTo(map); + // Esri 2-layer provider: add the labels reference overlay too + if (provider && provider.refUrl) { + try { L.tileLayer(provider.refUrl, { maxZoom: 18 }).addTo(map); } catch (_e) {} + } + // Apply invert CSS filter to the tile pane if the provider needs it + try { + var pane = map.getPane && map.getPane('tilePane'); + if (pane) pane.style.filter = (provider && provider.invertFilter) ? provider.invertFilter : ''; + } catch (_e) {} + return layer; + } + + // ROLE_COLORS loaded from shared roles.js const TABS = [ { key: 'all', label: 'All' }, @@ -676,7 +699,7 @@ try { if (detailMap) { detailMap.remove(); detailMap = null; } detailMap = L.map('nodeFullMap', { zoomControl: true, attributionControl: false }).setView([n.lat, n.lon], 13); - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 18 }).addTo(detailMap); + _applyTilesToNodeMap(detailMap); L.marker([n.lat, n.lon]).addTo(detailMap).bindPopup(n.name || n.public_key.slice(0, 12)); setTimeout(() => detailMap.invalidateSize(), 100); } catch {} @@ -1524,7 +1547,7 @@ try { if (detailMap) { detailMap.remove(); detailMap = null; } detailMap = L.map('nodeMap', { zoomControl: false, attributionControl: false }).setView([n.lat, n.lon], 13); - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 18 }).addTo(detailMap); + _applyTilesToNodeMap(detailMap); L.marker([n.lat, n.lon]).addTo(detailMap).bindPopup(n.name || n.public_key.slice(0, 12)); setTimeout(() => detailMap.invalidateSize(), 100); } catch {} diff --git a/public/roles.js b/public/roles.js index 68b5d2c6..022a40f1 100644 --- a/public/roles.js +++ b/public/roles.js @@ -363,7 +363,35 @@ var isDark = document.documentElement.getAttribute('data-theme') === 'dark' || (document.documentElement.getAttribute('data-theme') !== 'light' && window.matchMedia('(prefers-color-scheme: dark)').matches); - return isDark ? TILE_DARK : TILE_LIGHT; + if (!isDark) return TILE_LIGHT; + // #1461 followup: honor customizer's dark-tile-provider pick (#1420 / #1430) + // when the registry is loaded. Falls back to TILE_DARK if absent. + try { + if (window.MC_getDarkTileProvider && window.MC_TILE_PROVIDERS) { + var id = window.MC_getDarkTileProvider(); + var p = window.MC_TILE_PROVIDERS[id]; + if (p && (p.url || p.baseUrl)) { + return p.url || p.baseUrl; + } + } + } catch (_e) {} + return TILE_DARK; + }; + /* Helper: get the full provider object (for callers that also need the + * invertFilter or refUrl/attribution). Returns null when no customizer + * provider applies (light mode, or registry not loaded). */ + window.getActiveTileProvider = function () { + var isDark = document.documentElement.getAttribute('data-theme') === 'dark' || + (document.documentElement.getAttribute('data-theme') !== 'light' && + window.matchMedia('(prefers-color-scheme: dark)').matches); + if (!isDark) return null; + try { + if (window.MC_getDarkTileProvider && window.MC_TILE_PROVIDERS) { + var id = window.MC_getDarkTileProvider(); + return window.MC_TILE_PROVIDERS[id] || null; + } + } catch (_e) {} + return null; }; // ─── SNR thresholds ───