feat(nativegeocoder): add NativeGeocoder plugin (#800)

This commit is contained in:
Sebastian Baar 2017-01-20 21:56:16 +01:00 committed by Ibby Hadeed
parent db55342329
commit 911537b61b
2 changed files with 93 additions and 0 deletions

View File

@ -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,

View 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;
}