aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/Map.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/map/Map.js')
-rw-r--r--modern/src/map/Map.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js
index 8a43e97b..bbb1f5ce 100644
--- a/modern/src/map/Map.js
+++ b/modern/src/map/Map.js
@@ -35,7 +35,27 @@ const updateReadyValue = value => {
readyListeners.forEach(listener => listener(value));
};
+const onIdle = function () {
+ const zoom = Math.round(map.getZoom())
+ if (zoom !== map.getZoom()) {
+ map.zoomTo(zoom)
+ }
+};
+
+const isRasterMap = map => Object.values(map.getStyle().sources).some(e => e.type === 'raster');
+
+const setAllowedZoomLevels = map => {
+ if(isRasterMap(map)) {
+ map.scrollZoom.setWheelZoomRate(1);
+ map.on('idle', onIdle);
+ } else {
+ map.scrollZoom.setWheelZoomRate(1/450);
+ map.off('idle', onIdle);
+ }
+};
+
const initMap = async () => {
+ setAllowedZoomLevels(map);
const background = await loadImage('images/background.svg');
await Promise.all(deviceCategories.map(async category => {
if (!map.hasImage(category)) {