aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMustafa Taha Şahin <taha.sahin@metu.edu.tr>2021-04-01 00:29:15 +0300
committerMustafa Taha Şahin <taha.sahin@metu.edu.tr>2021-04-01 00:29:15 +0300
commitdfc2c4d23684b4dcce3e4d8a366e58040163ed51 (patch)
treea0f96abea4f540d8fc178049d921ced7c1157c88
parent9ccde8f4495d1a58e644ad36c1866cb91168d173 (diff)
downloadetbsa-traccar-web-dfc2c4d23684b4dcce3e4d8a366e58040163ed51.tar.gz
etbsa-traccar-web-dfc2c4d23684b4dcce3e4d8a366e58040163ed51.tar.bz2
etbsa-traccar-web-dfc2c4d23684b4dcce3e4d8a366e58040163ed51.zip
Limit zoom levels to integers for raster maps
-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 8a43e97..bbb1f5c 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)) {