diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-03 15:10:11 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-11-03 15:10:11 -0800 |
commit | 5e96fe64b49bb857fef1a2ac4d6522db332a89a0 (patch) | |
tree | 11a92950231c9b379a3e779c41e676493d785918 /modern/src/map | |
parent | 155e3b90365994a4bfbf3b43505f0452fb3fe88a (diff) | |
download | etbsa-traccar-web-5e96fe64b49bb857fef1a2ac4d6522db332a89a0.tar.gz etbsa-traccar-web-5e96fe64b49bb857fef1a2ac4d6522db332a89a0.tar.bz2 etbsa-traccar-web-5e96fe64b49bb857fef1a2ac4d6522db332a89a0.zip |
Add current location
Diffstat (limited to 'modern/src/map')
-rw-r--r-- | modern/src/map/CurrentLocationMap.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/modern/src/map/CurrentLocationMap.js b/modern/src/map/CurrentLocationMap.js new file mode 100644 index 0000000..31e6e28 --- /dev/null +++ b/modern/src/map/CurrentLocationMap.js @@ -0,0 +1,21 @@ +import mapboxgl from 'mapbox-gl'; +import { useEffect } from 'react'; +import { map } from './Map'; + +const CurrentLocationMap = () => { + useEffect(() => { + const control = new mapboxgl.GeolocateControl({ + positionOptions: { + enableHighAccuracy: true, + timeout: 5000, + }, + trackUserLocation: true, + }); + map.addControl(control); + return () => map.removeControl(control); + }, []); + + return null; +} + +export default CurrentLocationMap; |