From 7db5e5ca0aae68c7089bd1bbdbccc2a7e8ab0208 Mon Sep 17 00:00:00 2001 From: Shaun Beamish Date: Sun, 26 Jul 2020 15:39:46 +1200 Subject: [PATCH] Fixed GeoLocation not following users location when not using simulator. Altered the geoloaction.watchPosition improving its accuracy/ how often it polls the users location. --- src/components/MapViewNavigation/index.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/MapViewNavigation/index.js b/src/components/MapViewNavigation/index.js index 092a213a..c9e1fa9e 100644 --- a/src/components/MapViewNavigation/index.js +++ b/src/components/MapViewNavigation/index.js @@ -128,13 +128,20 @@ export default class MapViewNavigation extends Component { */ componentDidMount() { - this.watchId = navigator.geolocation.watchPosition(position => { - - this.setPosition(position.coords); - - }); + if (!this.props.simulate) { + this.watchId = geolocation.watchPosition(position => { + this.setPosition(position.coords); + }, + (err) => {console.error(err)}, + { enableHighAccuracy: true, timeout: 10, maximumAge: 0, distanceFilter: 0 }); + + } else { + this.watchId = navigator.geolocation.watchPosition(position => { + this.setPosition(position.coords); + }); + } } - + /** * @componentWillUnmount */