aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-11 16:39:34 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-11 16:39:34 -0700
commite34214fe32cafb19d871d3e20a2c5ad80de56a20 (patch)
tree8a251b69fe13c0b6e9276f64130c0489d3b9c1e2
parent7b703f07c6134046f80e2d859f5d607f024df191 (diff)
downloadtrackermap-web-e34214fe32cafb19d871d3e20a2c5ad80de56a20.tar.gz
trackermap-web-e34214fe32cafb19d871d3e20a2c5ad80de56a20.tar.bz2
trackermap-web-e34214fe32cafb19d871d3e20a2c5ad80de56a20.zip
Handle missing style selection
-rw-r--r--modern/src/map/switcher/switcher.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/modern/src/map/switcher/switcher.js b/modern/src/map/switcher/switcher.js
index 60a5eff7..d96f7ffc 100644
--- a/modern/src/map/switcher/switcher.js
+++ b/modern/src/map/switcher/switcher.js
@@ -16,7 +16,16 @@ export class SwitcherControl {
updateStyles(updatedStyles, defaultStyle) {
this.styles = updatedStyles;
- const selectedStyle = this.currentStyle || defaultStyle;
+ let selectedStyle = null;
+ for (const style of this.styles) {
+ if (style.id === (this.currentStyle || defaultStyle)) {
+ selectedStyle = style.id;
+ break;
+ }
+ }
+ if (!selectedStyle) {
+ this.styles[0].id;
+ }
while (this.mapStyleContainer.firstChild) {
this.mapStyleContainer.removeChild(this.mapStyleContainer.firstChild);