diff options
Diffstat (limited to 'modern/src/map/switcher/switcher.js')
-rw-r--r-- | modern/src/map/switcher/switcher.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/modern/src/map/switcher/switcher.js b/modern/src/map/switcher/switcher.js index 643b6ec0..a3805f6b 100644 --- a/modern/src/map/switcher/switcher.js +++ b/modern/src/map/switcher/switcher.js @@ -30,15 +30,17 @@ export class SwitcherControl { styleElement.type = 'button'; styleElement.innerText = style.title; styleElement.classList.add(style.title.replace(/[^a-z0-9-]/gi, '_')); - styleElement.dataset.uri = style.uri; + styleElement.dataset.uri = JSON.stringify(style.uri); styleElement.addEventListener('click', (event) => { const { srcElement } = event; if (srcElement.classList.contains('active')) { return; } this.beforeSwitch(); - let uri = srcElement.dataset.uri; - Object.entries(this.variables).forEach(([key, value]) => uri = uri.replaceAll(`$\{${key}}`, value)); + let uri = JSON.parse(srcElement.dataset.uri); + if (typeof uri === 'string') { + Object.entries(this.variables).forEach(([key, value]) => uri = uri.replaceAll(`$\{${key}}`, value)); + } this.map.setStyle(uri); this.afterSwitch(); this.mapStyleContainer.style.display = 'none'; |