react-native-gps
react-native-gps copied to clipboard
add RNLocation.endUpdatingLocation() method request
Hi, is there any odds to add the ability to stop listening the gps, thanks!
Hi @arcollector , when you use Location.stopUpdatingLocation(); still listening the gps?
oups, i didnt know that the method is called RNLocation.stopUpdatingLocation()
now my problem is that the map-marker icon is displaying in the status top bar (in android) regardless of previously calling this function
i found the solution to remove the map marker icon from the status bar, I need to save a reference from DeviceEventEmitter
output and then call remove
method from it, I only tested on android
import {
DeviceEventEmitter,
NativeModules,
} from 'react-native';
import type EmitterSubscription from 'EmitterSubscription';
type coordinates = {| latitude: number, longitude: number |};
export default class GPS {
eventEmitter: EmitterSubscription | null = null
init = (): void => {
const { RNLocation } = NativeModules;
RNLocation.startUpdatingLocation();
this.eventEmitter = DeviceEventEmitter.addListener(
'locationUpdated',
(position: coordinates): void => {
console.log('RNLocation', position);
this.onLocation(position);
}
);
}
uninit = (): void {
const { RNLocation } = NativeModules;
RNLocation.stopUpdatingLocation();
this.eventEmitter && this.eventEmitter.remove();
}
}