mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-08 18:39:40 +00:00
Update the map when making config changes (#3568)
This commit is contained in:
committed by
Paulus Schoutsen
parent
cf7a300614
commit
fcd206e94b
@@ -20,10 +20,19 @@ export const setupLeafletMap = async (
|
||||
style.setAttribute("rel", "stylesheet");
|
||||
mapElement.parentNode.appendChild(style);
|
||||
map.setView([52.3731339, 4.8903147], 13);
|
||||
Leaflet.tileLayer(
|
||||
createTileLayer(Leaflet, darkMode).addTo(map);
|
||||
|
||||
return [map, Leaflet];
|
||||
};
|
||||
|
||||
export const createTileLayer = (
|
||||
leaflet: LeafletModuleType,
|
||||
darkMode: boolean
|
||||
) => {
|
||||
return leaflet.tileLayer(
|
||||
`https://{s}.basemaps.cartocdn.com/${
|
||||
darkMode ? "dark_all" : "light_all"
|
||||
}/{z}/{x}/{y}${Leaflet.Browser.retina ? "@2x.png" : ".png"}`,
|
||||
}/{z}/{x}/{y}${leaflet.Browser.retina ? "@2x.png" : ".png"}`,
|
||||
{
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>, © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
@@ -31,7 +40,5 @@ export const setupLeafletMap = async (
|
||||
minZoom: 0,
|
||||
maxZoom: 20,
|
||||
}
|
||||
).addTo(map);
|
||||
|
||||
return [map, Leaflet];
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user