import { GaoDeLocation } from '@awesome-cordova-plugins/gao-de-location/ngx';
constructor(private gaoDeLocation: GaoDeLocation) { }
const positionOptions: PositionOptions = {
androidOption: {
locationMode: LocationModeEnum.Hight_Accuracy,
gpsFirst: false,
HttpTimeOut: 30000,
interval: 2000,
needAddress: true,
onceLocation: false,
onceLocationLatest: false,
locationProtocol: LocationProtocolEnum.HTTP,
sensorEnable: false,
wifiScan: true,
locationCacheEnable: true
}, iosOption: {
desiredAccuracy: DesiredAccuracyEnum.kCLLocationAccuracyBest,
pausesLocationUpdatesAutomatically: 'YES',
allowsBackgroundLocationUpdates: 'NO',
locationTimeout: 10,
reGeocodeTimeout: 5,
}
};
const positionRes: PositionRes = await this.gaoDeLocation.getCurrentPosition(positionOptions).catch((e: any) => {
console.log(e);
}) || null;
console.log(JSON.stringify(positionRes));
this.gaoDeLocation.startSerialLocation(positionOptions).subscribe((positionRes: PositionRes) => {
console.log(JSON.stringify(positionRes));
});
const positionRes: any = this.gaoDeLocation.stopSerialLocation().catch((e) => {
console.log(e);
}) || null;
console.log(JSON.stringify(positionRes));