aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modern/src/map/core/useMapStyles.js7
-rw-r--r--modern/src/map/switcher/switcher.js10
2 files changed, 12 insertions, 5 deletions
diff --git a/modern/src/map/core/useMapStyles.js b/modern/src/map/core/useMapStyles.js
index 7ab77ae2..ba9ac5a6 100644
--- a/modern/src/map/core/useMapStyles.js
+++ b/modern/src/map/core/useMapStyles.js
@@ -10,8 +10,8 @@ const styleCustom = ({ tiles, minZoom, maxZoom, attribution }) => ({
tiles,
attribution,
tileSize: 256,
- minzoom: minZoom,
- maxzoom: maxZoom,
+ minzoom: minZoom || 0,
+ maxzoom: maxZoom || 20,
},
},
glyphs: 'https://cdn.traccar.com/map/fonts/{fontstack}/{range}.pbf',
@@ -161,6 +161,9 @@ export default () => {
id: 'ordnanceSurvey',
title: t('mapOrdnanceSurvey'),
style: 'https://api.os.uk/maps/vector/v1/vts/resources/styles?key=EAZ8p83u72FTGiLjLC2MsTAl1ko6XQHC',
+ transformRequest: (url) => ({
+ url: `${url}&srs=3857`,
+ }),
available: true,
},
{
diff --git a/modern/src/map/switcher/switcher.js b/modern/src/map/switcher/switcher.js
index 8fe48929..ee0f41ed 100644
--- a/modern/src/map/switcher/switcher.js
+++ b/modern/src/map/switcher/switcher.js
@@ -15,6 +15,10 @@ export class SwitcherControl {
return 'top-right';
}
+ getStyle(id) {
+ return this.styles.find((it) => it.id === id);
+ }
+
updateStyles(updatedStyles, defaultStyle) {
this.styles = updatedStyles;
@@ -63,9 +67,9 @@ export class SwitcherControl {
onSelectStyle(target) {
this.onBeforeSwitch();
- this.map.setStyle(JSON.parse(target.dataset.style), {
- diff: false,
- });
+ const style = this.getStyle(target.dataset.id);
+ this.map.setStyle(style.style, { diff: false });
+ this.map.setTransformRequest(style.transformRequest);
this.onSwitch(target.dataset.id);