I know this library is purposed for background geolocation that listen geo movement. But my usage is: I want to capture current location, if I got current location, then stop to listen. It can be a button that refresh current geo every time I click button. I want to replicate RN built-in geolocation getCurrentPosition, which is make me very frustrate because of bug. I just want to make sure that this library can accommodate my usage, so I ask here. Thanks.
@pewh Did you find a way to find current location?
Unfortunately, no :/
Current solution in official RN is still buggy, and I still don't have any solution with this repo
Hmm... thanks. I am thinking of implementing it natively, but I am completely new to RN. If I can find a solution, I will share the implementation.
so just start and on location event stop service :) but in general is this good idea? bcs you need some time to get better accuracy
Solution taken from the example app:
toggleTracking() {
if (this.state.isTracking) {
this.stopTracking();
} else {
this.startTracking();
}
}
startTracking() {
if (this.state.isTracking) { return; }
BackgroundGeolocation.start(() => {
console.log('[DEBUG] BackgroundGeolocation started successfully');
});
this.setState({ isTracking: true });
}
stopTracking() {
if (!this.state.isTracking) { return; }
BackgroundGeolocation.stop();
this.setState({ isTracking: false });
}
const Button = this.state.isTracking ? <Text>Stop</Text> : <Text>Start</Text>;
<TouchableOpacity onPress={this.toggleTracking.bind(this)}>
{Button}
</TouchableOpacity>
Notice: this issue has been closed because it has been inactive for 73 days. You may reopen this issue if it has been closed in error.
Most helpful comment
Hmm... thanks. I am thinking of implementing it natively, but I am completely new to RN. If I can find a solution, I will share the implementation.