update admin light/dark mode
This commit is contained in:
@@ -14,12 +14,27 @@ export const initMap = (containerId) => {
|
||||
position: 'bottomright'
|
||||
}).addTo(map);
|
||||
|
||||
// Tile Layer Premium (CartoDB Dark Matter untuk Glass UI)
|
||||
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', {
|
||||
const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
|
||||
const tileUrl = isDark
|
||||
? 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png'
|
||||
: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png';
|
||||
|
||||
// Tile Layer Premium (CartoDB Dark Matter / Light All)
|
||||
const tileLayer = L.tileLayer(tileUrl, {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
subdomains: 'abcd',
|
||||
maxZoom: 20
|
||||
}).addTo(map);
|
||||
|
||||
// Dynamic theme updater for tile layer
|
||||
const observer = new MutationObserver(() => {
|
||||
const dark = document.documentElement.getAttribute('data-theme') === 'dark';
|
||||
tileLayer.setUrl(dark
|
||||
? 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png'
|
||||
: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png'
|
||||
);
|
||||
});
|
||||
observer.observe(document.documentElement, { attributes: true });
|
||||
|
||||
return map;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user