aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorMustafa Taha Şahin <taha.sahin@metu.edu.tr>2021-04-02 01:14:03 +0300
committerMustafa Taha Şahin <taha.sahin@metu.edu.tr>2021-04-02 01:14:03 +0300
commit203df66558a9d92dce11d6121e576886d29c2e77 (patch)
treec9c35400d2e9f909b4aab394da998be2e53e4c84 /modern/src
parentd4e94f135a4092186deda57bc53ad38154cdb401 (diff)
downloadetbsa-traccar-web-203df66558a9d92dce11d6121e576886d29c2e77.tar.gz
etbsa-traccar-web-203df66558a9d92dce11d6121e576886d29c2e77.tar.bz2
etbsa-traccar-web-203df66558a9d92dce11d6121e576886d29c2e77.zip
more refactoring
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/map/Map.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js
index 4bdf2fd..7f78973 100644
--- a/modern/src/map/Map.js
+++ b/modern/src/map/Map.js
@@ -42,18 +42,7 @@ const onIdle = function () {
}
};
-const setAllowedZoomLevels = map => {
- if (Object.values(map.getStyle().sources).some(e => e.type === 'raster')) {
- 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)) {
@@ -111,6 +100,17 @@ const Map = ({ children }) => {
};
}, []);
+ useEffect(() => {
+ if (mapReady && Object.values(map.getStyle().sources).some(e => e.type === 'raster')) {
+ map.scrollZoom.setWheelZoomRate(1);
+ map.on('idle', onIdle);
+ }
+ return () => {
+ map.scrollZoom.setWheelZoomRate(1/450);
+ map.off('idle', onIdle);
+ }
+ }, [mapReady]);
+
useLayoutEffect(() => {
const currentEl = containerEl.current;
currentEl.appendChild(element);