diff --git a/CHANGELOG.md b/CHANGELOG.md index 3edf4ba8..ecc0f48b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/javascript/maps/layers.js b/app/javascript/maps/layers.js index 96334e6a..27e544a4 100644 --- a/app/javascript/maps/layers.js +++ b/app/javascript/maps/layers.js @@ -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; });