diff options
author | rahighi <rahighi> | 2021-08-28 09:41:25 +0430 |
---|---|---|
committer | rahighi <rahighi> | 2021-08-28 09:41:25 +0430 |
commit | 545f0d8223e88631f8d7c13077ffe5bae78716cb (patch) | |
tree | 51d4c2132b2136208c0f18603ff6bf53b2983fd3 /modern/src/map | |
parent | 332681f36dc9814e51c61d0e310f6c5d8a0f0c20 (diff) | |
download | trackermap-web-545f0d8223e88631f8d7c13077ffe5bae78716cb.tar.gz trackermap-web-545f0d8223e88631f8d7c13077ffe5bae78716cb.tar.bz2 trackermap-web-545f0d8223e88631f8d7c13077ffe5bae78716cb.zip |
Only multiple language support feature
Diffstat (limited to 'modern/src/map')
-rw-r--r-- | modern/src/map/CurrentLocationMap.js | 9 | ||||
-rw-r--r-- | modern/src/map/Map.js | 25 |
2 files changed, 6 insertions, 28 deletions
diff --git a/modern/src/map/CurrentLocationMap.js b/modern/src/map/CurrentLocationMap.js index c875662d..69724ce1 100644 --- a/modern/src/map/CurrentLocationMap.js +++ b/modern/src/map/CurrentLocationMap.js @@ -1,14 +1,9 @@ import maplibregl from 'maplibre-gl'; import { useEffect } from 'react'; -import { useLocalization } from '../common/localization'; import { map } from './Map'; const CurrentLocationMap = () => { - const {direction} = useLocalization(); - useEffect(() => { - const controlsPosition = direction ==='rtl' ? 'top-left' : 'top-right'; - const control = new maplibregl.GeolocateControl({ positionOptions: { enableHighAccuracy: true, @@ -16,9 +11,9 @@ const CurrentLocationMap = () => { }, trackUserLocation: true, }); - map.addControl(control,controlsPosition); + map.addControl(control); return () => map.removeControl(control); - }, [direction]); + }, []); return null; }; diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js index 64fc31a0..47ebb1f0 100644 --- a/modern/src/map/Map.js +++ b/modern/src/map/Map.js @@ -7,10 +7,10 @@ import React, { import { SwitcherControl } from './switcher/switcher'; import deviceCategories from '../common/deviceCategories'; import { prepareIcon, loadImage } from './mapUtil'; -import t, { useLocalization } from '../common/localization'; import { styleCarto, styleMapbox, styleMapTiler, styleOsm, } from './mapStyles'; +import t from '../common/localization'; import { useAttributePreference } from '../common/preferences'; import palette from '../theme/palette'; @@ -64,9 +64,9 @@ const initMap = async () => { map.on('load', initMap); -const navigationControl = new maplibregl.NavigationControl({ +map.addControl(new maplibregl.NavigationControl({ showCompass: false, -}) +})); const switcher = new SwitcherControl( [ @@ -92,32 +92,15 @@ const switcher = new SwitcherControl( }, ); -const addPrimaryControls = position => { - map.addControl(navigationControl, position); - map.addControl(switcher, position); -} - -const removePrimaryControls =()=> { - map.removeControl(navigationControl); - map.removeControl(switcher); -} - - map.addControl(switcher); const Map = ({ children }) => { const containerEl = useRef(null); - const {direction} = useLocalization(); + const [mapReady, setMapReady] = useState(false); const mapboxAccessToken = useAttributePreference('mapboxAccessToken'); - useEffect(()=>{ - const controlsPosition = direction ==='rtl' ? 'top-left' : 'top-right'; - addPrimaryControls(controlsPosition); - return removePrimaryControls; - },[direction]) - useEffect(() => { maplibregl.accessToken = mapboxAccessToken; }, [mapboxAccessToken]); |