Apologies if this isn't the right place to be asking this question.
I've noticed that when I activate the _showsUserLocation_ feature, the blue dot that shows my location seems to receive frequent updates, far more than my RN code does when I call geolocation.watchPosition
without any parameters:
this._geolocation.watchPosition(
(gps) => {
// ...
},
(err) => {
console.log("Failed to get gpsPosition", err);
}
);
Is there a way to get the same updates in my RN app that react-native-maps seems to receive?
I used a timer to force updates at a 3 second rate.
I am not recommending what I did, it may be a very bad idea, but it achieved my goal of faster updates.
const MyMapView = React.createClass({
mixins: [TimerMixin],
watchID: null,
getCurrentPosition() {
navigator.geolocation.getCurrentPosition(this.geoSuccess, this.geoError, this.options);
},
geoWatchStart() {
if (this.watchID != null) {
return;
}
this.getCurrentPosition();
this.watchID = navigator.geolocation.watchPosition(this.geoSuccess, this.geoError, this.options);
},
geoWatchStop() {
if (this.watchID == null) {
return;
}
console.log('WaypointScreen:geoWatchStop');
navigator.geolocation.clearWatch(this.watchID);
this.watchID = null;
},
componentDidMount() {
// Use timer to force GPS update
// watchPosition updates too slowly, maybe every 10 seconds
this.setInterval(
() => {
this.geoWatchStop();
this.geoWatchStart();
}, 3000
);
},
+1 and ideally not what @esutton did....
Play with options:
https://facebook.github.io/react-native/docs/geolocation.html#watchposition