mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-06-06 14:31:42 +00:00
feat(#1470): node-detail map inset honors customizer dark-tile provider
Follow-up to #1430. The node-detail inset map previously hardcoded OSM light tiles, ignoring the customizer dark-tile pick. - Add _applyTilesToNodeMap helper in nodes.js (single source of truth for the inset map's tile layer) - Wire the helper into the 2 call-sites that render the inset map - Add getActiveTileProvider() to roles.js and route getTileUrl() through MC_TILE_PROVIDERS so the inset reads from the same registry as the main map - Apply CSS invert filter for inverted provider variants
This commit is contained in:
+25
-2
@@ -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 {}
|
||||
|
||||
+29
-1
@@ -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 ───
|
||||
|
||||
Reference in New Issue
Block a user