-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gao-de-location): add plugin (#2857)
* Add a gaode Map Location * 增加详细的返回信息 * Return type has been added * Update index.ts
- Loading branch information
1 parent
c3de8df
commit e2b25de
Showing
1 changed file
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core'; | ||
|
||
/** | ||
* @name Gao De Location | ||
* @description | ||
* Because the original GPS positioning uses Google Browser positioning, and Google withdraws from China, resulting in GPS Android positioning can not be positioned. | ||
* Gaode location can directly return address informationGaode location can directly return address information | ||
* | ||
* @usage | ||
* ```typescript | ||
* import { GaoDeLocation } from '@ionic-native/gao-de-location'; | ||
* | ||
* | ||
* constructor(private gaoDeLocation: GaoDeLocation) { } | ||
* | ||
* this.gaoDeLocation.getCurrentPosition() | ||
* .then((res: PositionOptions) => console.log(res)) | ||
* .catch((error) => console.error(error)); | ||
* | ||
* ``` | ||
*/ | ||
@Plugin({ | ||
pluginName: 'GaoDeLocation', | ||
plugin: 'cordova-plugin-gaodelocation-chenyu', | ||
pluginRef: 'GaoDe', | ||
repo: 'https://github.com/waliu/cordova-plugin-gaodelocation-chenyu.git', | ||
install: 'ionic cordova plugin add cordova-plugin-gaodelocation-chenyu --variable ANDROID_API_KEY=your android key --variable IOS_API_KEY=your ios key', | ||
installVariables: ['ANDROID_API_KEY', 'IOS_API_KEY'], | ||
platforms: ['Android', 'iOS'] | ||
}) | ||
@Injectable() | ||
export class GaoDeLocation extends IonicNativePlugin { | ||
/** | ||
* Get longitude and latitude, country, province, city, postal code, specific address, region | ||
* @returns {Promise<PositionOptions>} | ||
*/ | ||
@Cordova() | ||
getCurrentPosition(): Promise<PositionOptions> { | ||
return; | ||
} | ||
|
||
} | ||
|
||
export interface PositionOptions { | ||
/* | ||
* latitude | ||
* */ | ||
latitude: number; | ||
/* | ||
* longitude | ||
* */ | ||
longitude: number; | ||
/* | ||
* ios Horizontal accuracy,android accuracy | ||
* */ | ||
accuracy: string; | ||
/* | ||
* Postal Code | ||
* */ | ||
adcode: string; | ||
/* | ||
* Detailed address | ||
* */ | ||
address: string; | ||
/* | ||
* city | ||
* */ | ||
city: string; | ||
/* | ||
* city Code | ||
* */ | ||
citycode: string; | ||
/* | ||
* country | ||
* */ | ||
country: string; | ||
/* | ||
* district | ||
* */ | ||
district: string; | ||
/* | ||
* Address name | ||
* */ | ||
poi: string; | ||
/* | ||
* province | ||
* */ | ||
province: string; | ||
/* | ||
* The state of the calling plug-in | ||
* */ | ||
status: string; | ||
/* | ||
* Location type | ||
* */ | ||
type: string; | ||
/* | ||
* Android Location time, ios void | ||
* **/ | ||
time?: string; | ||
/* | ||
* backtime, ios void | ||
* **/ | ||
backtime?: string; | ||
/* | ||
* angle | ||
* */ | ||
bearing?: string; | ||
/* | ||
* Number of satellites, ios void | ||
* */ | ||
satellites?: string; | ||
} |