mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 00:12:53 +08:00
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:
parent
83bb4a96f9
commit
bfee712cdc
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop Serial Location
|
||||||
|
* @return Promise<any>
|
||||||
|
*/
|
||||||
|
@Cordova({
|
||||||
|
callbackOrder: 'reverse',
|
||||||
|
})
|
||||||
|
stopSerialLocation(): Promise<any> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location parameter
|
||||||
|
*/
|
||||||
export interface PositionOptions {
|
export interface PositionOptions {
|
||||||
/*
|
/**
|
||||||
* latitude
|
* android options
|
||||||
* */
|
*/
|
||||||
latitude: number;
|
androidOption: AndroidOptions;
|
||||||
/*
|
/**
|
||||||
* longitude
|
* ios options
|
||||||
* */
|
*/
|
||||||
longitude: number;
|
iosOption: IosOptions;
|
||||||
/*
|
}
|
||||||
* ios Horizontal accuracy,android accuracy
|
|
||||||
* */
|
/**
|
||||||
accuracy: string;
|
* android positioning accuracy
|
||||||
/*
|
*/
|
||||||
* Postal Code
|
export interface AndroidOptions {
|
||||||
* */
|
/**
|
||||||
adcode: string;
|
* location mode
|
||||||
/*
|
*/
|
||||||
* Detailed address
|
locationMode: LocationModeEnum;
|
||||||
* */
|
/**
|
||||||
address: string;
|
* gps first
|
||||||
/*
|
*/
|
||||||
* city
|
gpsFirst: boolean;
|
||||||
* */
|
/**
|
||||||
city: string;
|
* Http timeOut
|
||||||
/*
|
*/
|
||||||
* city Code
|
HttpTimeOut: number;
|
||||||
* */
|
/**
|
||||||
citycode: string;
|
* Location interval
|
||||||
/*
|
*/
|
||||||
* country
|
interval: number;
|
||||||
* */
|
/**
|
||||||
country: string;
|
* Open reverse address
|
||||||
/*
|
*/
|
||||||
* district
|
needAddress: boolean;
|
||||||
* */
|
/**
|
||||||
district: string;
|
* once location
|
||||||
/*
|
*/
|
||||||
* Address name
|
onceLocation: boolean;
|
||||||
* */
|
/**
|
||||||
poi: string;
|
* once location latest
|
||||||
/*
|
*/
|
||||||
* province
|
onceLocationLatest: boolean;
|
||||||
* */
|
/**
|
||||||
province: string;
|
* location protocol
|
||||||
/*
|
*/
|
||||||
* The state of the calling plug-in
|
locationProtocol: LocationProtocolEnum;
|
||||||
* */
|
/**
|
||||||
status: string;
|
* sensor enable
|
||||||
/*
|
*/
|
||||||
* Location type
|
sensorEnable: boolean;
|
||||||
* */
|
/**
|
||||||
type: string;
|
* wifi scan
|
||||||
/*
|
*/
|
||||||
* Android Location time, ios void
|
wifiScan: boolean;
|
||||||
* **/
|
/**
|
||||||
time?: string;
|
* location cache enable
|
||||||
/*
|
*/
|
||||||
* backtime, ios void
|
locationCacheEnable: boolean;
|
||||||
* **/
|
}
|
||||||
backtime?: string;
|
|
||||||
/*
|
|
||||||
* angle
|
/**
|
||||||
* */
|
*
|
||||||
bearing?: string;
|
* IOS positioning parameters
|
||||||
/*
|
*
|
||||||
* Number of satellites, ios void
|
*/
|
||||||
* */
|
export interface IosOptions {
|
||||||
satellites?: string;
|
/**
|
||||||
|
* 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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user