mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
feat(nativegeocoder): add NativeGeocoder plugin (#800)
This commit is contained in:
parent
db55342329
commit
911537b61b
@ -70,6 +70,7 @@ import { LocalNotifications } from './plugins/localnotifications';
|
||||
import { LocationAccuracy } from './plugins/location-accuracy';
|
||||
import { MediaCapture } from './plugins/media-capture';
|
||||
import { NativeAudio } from './plugins/native-audio';
|
||||
import { NativeGeocoder } from './plugins/native-geocoder';
|
||||
import { NativePageTransitions } from './plugins/native-page-transitions';
|
||||
import { NativeStorage } from './plugins/nativestorage';
|
||||
import { Market } from './plugins/market';
|
||||
@ -183,6 +184,7 @@ export * from './plugins/media-capture';
|
||||
export * from './plugins/mixpanel';
|
||||
export * from './plugins/music-controls';
|
||||
export * from './plugins/native-audio';
|
||||
export * from './plugins/native-geocoder';
|
||||
export * from './plugins/native-page-transitions';
|
||||
export * from './plugins/nativestorage';
|
||||
export * from './plugins/network';
|
||||
@ -293,6 +295,7 @@ window['IonicNative'] = {
|
||||
Mixpanel,
|
||||
MusicControls,
|
||||
NativeAudio,
|
||||
NativeGeocoder,
|
||||
NativePageTransitions,
|
||||
NativeStorage,
|
||||
Network,
|
||||
|
90
src/plugins/native-geocoder.ts
Normal file
90
src/plugins/native-geocoder.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import { Plugin, Cordova } from './plugin';
|
||||
|
||||
/**
|
||||
* @name NativeGeocoder
|
||||
* @description
|
||||
* Cordova plugin for native forward and reverse geocoding
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { NativeGeocoder } from 'ionic-native';
|
||||
*
|
||||
* NativeGeocoder.reverseGeocode(52.5072095, 13.1452818)
|
||||
* .then((result: ReverseResult) => console.log("The address is " + result.address + " in " + result.countryCode))
|
||||
* .catch((error: any) => console.log(error));
|
||||
*
|
||||
* NativeGeocoder.forwardGeocode("Berlin")
|
||||
* .then((coordinates: ForwardResult) => console.log("The coordinates are latitude=" + coordinates.latitude + " and longitude=" + coordinates.longitude))
|
||||
* .catch((error: any) => console.log(error));
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
name: 'NativeGeocoder',
|
||||
plugin: 'cordova-plugin-nativegeocoder',
|
||||
pluginRef: 'nativegeocoder',
|
||||
repo: 'https://github.com/sebastianbaar/cordova-plugin-nativegeocoder',
|
||||
platforms: ['iOS', 'Android']
|
||||
})
|
||||
export class NativeGeocoder {
|
||||
|
||||
/**
|
||||
* Reverse geocode a given latitude and longitude to find location address
|
||||
* @param latitude {number} The latitude
|
||||
* @param longitude {number} The longitude
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
static reverseGeocode(latitude: number, longitude: number): Promise<ReverseResult> { return; }
|
||||
|
||||
/**
|
||||
* Forward geocode a given address to find coordinates
|
||||
* @param addressString {string} The address to be geocoded
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
static forwardGeocode(addressString: string): Promise<ForwardResult> { return; }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates format information about a reverse geocoding result.
|
||||
*/
|
||||
export interface ReverseResult {
|
||||
/**
|
||||
* The street.
|
||||
*/
|
||||
street: string;
|
||||
/**
|
||||
* The house number.
|
||||
*/
|
||||
houseNumber: string;
|
||||
/**
|
||||
* The postal code.
|
||||
*/
|
||||
postalCode: string;
|
||||
/**
|
||||
* The city.
|
||||
*/
|
||||
city: string;
|
||||
/**
|
||||
* The country name.
|
||||
*/
|
||||
countryName: string;
|
||||
/**
|
||||
* The country code.
|
||||
*/
|
||||
countryCode: string;
|
||||
}
|
||||
/**
|
||||
* Encapsulates format information about a forward geocoding result.
|
||||
*/
|
||||
export interface ForwardResult {
|
||||
/**
|
||||
* The latitude.
|
||||
*/
|
||||
latitude: string;
|
||||
/**
|
||||
* The longitude.
|
||||
*/
|
||||
longitude: string;
|
||||
}
|
Loading…
Reference in New Issue
Block a user