Fix missing default map layer when user settings are not set

This commit is contained in:
Eugene Burmakin 2025-10-07 22:25:41 +02:00
parent cde5af7c24
commit d3aa3bd067
2 changed files with 11 additions and 2 deletions

View file

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed a bug where user could not be deleted due to counter cache on points. #1818
- Introduce apt-get upgrade before installing new packages in the docker image to prevent vulnerabilities. #1793
- Fixed time shift when creating visits manually. #1679
- Provide default map layer if user settings are not set.
# [0.33.0] - 2025-09-29

View file

@ -50,9 +50,17 @@ export function createAllMapLayers(map, selectedLayerName, selfHosted) {
const layers = {};
const mapsConfig = selfHosted === "true" ? rasterMapsConfig : vectorMapsConfig;
// Determine the default layer based on self-hosted mode
const defaultLayerName = selfHosted === "true" ? "OpenStreetMap" : "Light";
// If selectedLayerName is null/undefined or doesn't exist in config, use default
const layerToSelect = selectedLayerName && mapsConfig[selectedLayerName]
? selectedLayerName
: defaultLayerName;
Object.keys(mapsConfig).forEach(layerKey => {
// Create the layer and add it to the map if it's the user's selected layer
const layer = createMapLayer(map, selectedLayerName, layerKey, selfHosted);
// Create the layer and add it to the map if it's the selected/default layer
const layer = createMapLayer(map, layerToSelect, layerKey, selfHosted);
layers[layerKey] = layer;
});