blob: c875662d293461ed07d5cec4ff224ed98342e766 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
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,
timeout: 5000,
},
trackUserLocation: true,
});
map.addControl(control,controlsPosition);
return () => map.removeControl(control);
}, [direction]);
return null;
};
export default CurrentLocationMap;
|