diff --git a/app/component/MapLayersDialogContent.js b/app/component/MapLayersDialogContent.js
index ad17049d13..e65c2fa9cc 100644
--- a/app/component/MapLayersDialogContent.js
+++ b/app/component/MapLayersDialogContent.js
@@ -137,16 +137,16 @@ class MapLayersDialogContent extends React.Component {
(l.category === undefined || l.category === category),
)
.map(layer => {
- const key = layer.id || layer.url;
+ const id = layer.id || layer.url;
return {
- key,
+ key: layer.code || id,
checked:
- (layer.isOffByDefault && geoJson[key] === true) ||
- (!layer.isOffByDefault && geoJson[key] !== false), // todo: is active?
+ (layer.isOffByDefault && geoJson[id] === true) ||
+ (!layer.isOffByDefault && geoJson[id] !== false), // todo: is active?
defaultMessage: layer.name?.[lang] || layer.defaultMessage,
labelId: layer.labelId, // todo: rename?
icon: layer.icon,
- settings: { geoJson: key },
+ settings: { geoJson: id },
};
}) || []
);
@@ -211,7 +211,7 @@ class MapLayersDialogContent extends React.Component {
return {
checked,
label: translations[intl.locale],
- key: `map-layer-${code}`,
+ key: code,
categories: categories?.map(category => ({
...category,
settings: category.code,
@@ -242,6 +242,24 @@ class MapLayersDialogContent extends React.Component {
({ code }) => code === 'health_and_social_services',
);
+ const sortLayersByKey = (a, b) => {
+ // Retrieve the order of the layers from the configuration.
+ // Top- and Sub-level category codes are considered.
+ const layerOrder =
+ config.layers
+ ?.flatMap(category => category.categories || category)
+ .map(category => [
+ category.code,
+ // Retrieve order of sub-categories if they exist
+ ...(category.categories
+ ? category.categories.map(({ code }) => code)
+ : []),
+ ])
+ .flat() || [];
+
+ return layerOrder.indexOf(a.key) - layerOrder.indexOf(b.key);
+ };
+
return (
<>
diff --git a/app/configurations/config.herrenberg.js b/app/configurations/config.herrenberg.js
index 5711494330..f17d350186 100644
--- a/app/configurations/config.herrenberg.js
+++ b/app/configurations/config.herrenberg.js
@@ -354,6 +354,7 @@ export default configMerger(parentConfig, {
layers: [
// bicycleinfrastructure includes shops, repair stations,
{
+ code: 'bike_repair',
name: {
fi: '',
en: 'Service stations and stores',
@@ -365,6 +366,7 @@ export default configMerger(parentConfig, {
},
// Bicycle network layer
{
+ code: 'cycle_network',
name: {
fi: '',
en: "Bicycle network",
@@ -381,6 +383,7 @@ export default configMerger(parentConfig, {
},
// LoRaWan map layer
{
+ code: 'loarawan_gateways',
name: {
fi: '',
en: 'LoRaWAN Gateways',
@@ -393,6 +396,7 @@ export default configMerger(parentConfig, {
},
// Nette Toilette layer
{
+ code: 'friendly_toilet',
name: {
fi: '',
en: 'Public Toilets',
@@ -404,6 +408,7 @@ export default configMerger(parentConfig, {
icon: 'icon-icon_public_toilets',
},
{
+ code: 'sights',
name: {
fi: '',
en: 'sights',
@@ -415,6 +420,7 @@ export default configMerger(parentConfig, {
icon: 'icon-icon_sights',
},
{
+ code: 'school_route_map',
name: {
fi: '',
en: 'School route map',