From 5e96fe64b49bb857fef1a2ac4d6522db332a89a0 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 3 Nov 2020 15:10:11 -0800 Subject: Add current location --- modern/src/map/CurrentLocationMap.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 modern/src/map/CurrentLocationMap.js (limited to 'modern/src/map/CurrentLocationMap.js') diff --git a/modern/src/map/CurrentLocationMap.js b/modern/src/map/CurrentLocationMap.js new file mode 100644 index 00000000..31e6e285 --- /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; -- cgit v1.2.3