feat(gao-de-location): update wrapper to match version 2.0.5 (#3358)

* Plug in update to 2.0.5

* Plug in update to 2.0.5
This commit is contained in:
waliu 2020-04-16 03:29:07 +08:00 committed by GitHub
parent 83bb4a96f9
commit bfee712cdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs';
/** /**
* @name Gao De Location * @name Gao De Location
@ -14,9 +15,42 @@ import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
* *
* constructor(private gaoDeLocation: GaoDeLocation) { } * constructor(private gaoDeLocation: GaoDeLocation) { }
* *
* this.gaoDeLocation.getCurrentPosition() *
* .then((res: PositionOptions) => console.log(res)) * const positionOptions: PositionOptions = {
* .catch((error) => console.error(error)); * 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));
* *
* ``` * ```
*/ */
@ -32,83 +66,288 @@ import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
@Injectable() @Injectable()
export class GaoDeLocation extends IonicNativePlugin { export class GaoDeLocation extends IonicNativePlugin {
/** /**
* Get longitude and latitude, country, province, city, postal code, specific address, region * Single location
* @returns {Promise<PositionOptions>} * @param positionOptions
* @return Promise<PositionRes>
*/ */
@Cordova() @Cordova(
getCurrentPosition(): Promise<PositionOptions> { {
callbackOrder: 'reverse',
}
)
getCurrentPosition(positionOptions: PositionOptions): Promise<PositionRes> {
return; return;
} }
/**
* Start serial location
* @param positionOptions
* @return Promise<PositionRes>
*/
@Cordova({
callbackOrder: 'reverse',
observable: true
})
startSerialLocation(positionOptions: PositionOptions): Observable<PositionRes> {
return;
} }
export interface PositionOptions { /**
/* * Stop Serial Location
* latitude * @return Promise<any>
* */ */
latitude: number; @Cordova({
/* callbackOrder: 'reverse',
* longitude })
* */ stopSerialLocation(): Promise<any> {
longitude: number; return;
/* }
* ios Horizontal accuracy,android accuracy }
* */
accuracy: string; /**
/* * Location parameter
* Postal Code */
* */ export interface PositionOptions {
adcode: string; /**
/* * android options
* Detailed address */
* */ androidOption: AndroidOptions;
address: string; /**
/* * ios options
* city */
* */ iosOption: IosOptions;
city: string; }
/*
* city Code /**
* */ * android positioning accuracy
citycode: string; */
/* export interface AndroidOptions {
* country /**
* */ * location mode
country: string; */
/* locationMode: LocationModeEnum;
* district /**
* */ * gps first
district: string; */
/* gpsFirst: boolean;
* Address name /**
* */ * Http timeOut
poi: string; */
/* HttpTimeOut: number;
* province /**
* */ * Location interval
province: string; */
/* interval: number;
* The state of the calling plug-in /**
* */ * Open reverse address
status: string; */
/* needAddress: boolean;
* Location type /**
* */ * once location
type: string; */
/* onceLocation: boolean;
* Android Location time, ios void /**
* **/ * once location latest
time?: string; */
/* onceLocationLatest: boolean;
* backtime, ios void /**
* **/ * location protocol
backtime?: string; */
/* locationProtocol: LocationProtocolEnum;
* angle /**
* */ * sensor enable
bearing?: string; */
/* sensorEnable: boolean;
* Number of satellites, ios void /**
* */ * wifi scan
satellites?: string; */
wifiScan: boolean;
/**
* location cache enable
*/
locationCacheEnable: boolean;
}
/**
*
* IOS positioning parameters
*
*/
export interface IosOptions {
/**
* desired accuracy
*/
desiredAccuracy?: DesiredAccuracyEnum;
/**
* pauses location updates automatically
*/
pausesLocationUpdatesAutomatically: IosBoolean;
/**
* allows background location updates
*/
allowsBackgroundLocationUpdates: IosBoolean;
/**
* location timeout
*/
locationTimeout: number;
/**
* re geocode timeout
*/
reGeocodeTimeout?: number;
/**
* locating with re geocode
*/
locatingWithReGeocode?: IosBoolean;
}
/**
* ios positioning accuracy
* https://developer.apple.com/documentation/corelocation/kcllocationaccuracybestfornavigation
*/
export enum DesiredAccuracyEnum {
/**
* The highest possible accuracy that uses additional sensor data to facilitate navigation apps.
*/
kCLLocationAccuracyBestForNavigation = 1,
/**
* The best level of accuracy available.
*/
kCLLocationAccuracyBest = 2,
/**
* Accurate to within ten meters of the desired target.
*/
kCLLocationAccuracyNearestTenMeters = 3,
/**
* Accurate to within one hundred meters.
*/
kCLLocationAccuracyHundredMeters = 4,
/**
* Accurate to the nearest kilometer.
*/
kCLLocationAccuracyKilometer = 5,
/**
* Accurate to the nearest three kilometers.
*/
kCLLocationAccuracyThreeKilometers = 6
}
/**
* locationModeEnum
*/
export enum LocationModeEnum {
Hight_Accuracy = 1,
Battery_Saving = 2,
Device_Sensors = 3,
}
/**
* locationProtocolEnum
*/
export enum LocationProtocolEnum {
HTTP = 1,
HTTPS = 2
}
/**
* ios boolean
*/
export declare type IosBoolean = 'YES' | 'NO';
/**
* Positioning return result
*/
export interface PositionRes {
/**
* Status code
*/
code: number;
/**
* latitude
*/
latitude: string;
/**
* longitude
*/
longitude: string;
/**
* accuracy
*/
accuracy: string;
/**
* address
*/
formattedAddress: string;
/**
* country
*/
country: string;
/**
* province
*/
province: string;
/**
* city
*/
city: string;
/**
* district
*/
district: string;
/**
* citycode
*/
citycode: string;
/**
* adcode
*/
adcode: string;
/**
* street
*/
street: string;
/**
* Street number information
*/
number: string;
/**
* POI name
*/
POIName: string;
/**
* AOI Name
*/
AOIName: string;
/**
* altitude
*/
altitude?: string;
/**
* speed
*/
speed?: string;
/**
* bearing
*/
bearing?: string;
/**
* building id
*/
buildingId?: string;
/**
* floor
*/
floor?: string;
/**
* gps accuracy status
*/
gpsAccuracyStatus?: string;
/**
* Get location result source
*/
locationType?: string;
/**
* Location detail
*/
locationDetail?: string;
} }