2017-01-20 21:56:16 +01:00
import { Plugin , Cordova } from './plugin' ;
/ * *
* @name NativeGeocoder
* @description
* Cordova plugin for native forward and reverse geocoding
*
* @usage
* ` ` ` typescript
2017-01-20 16:01:29 -05:00
* import { NativeGeocoder , NativeGeocoderReverseResult , NativeGeocoderForwardResult } from 'ionic-native' ;
2017-01-20 21:56:16 +01:00
*
* NativeGeocoder . reverseGeocode ( 52.5072095 , 13.1452818 )
2017-01-20 16:01:29 -05:00
* . then ( ( result : NativeGeocoderReverseResult ) = > console . log ( "The address is " + result . address + " in " + result . countryCode ) )
2017-01-20 21:56:16 +01:00
* . catch ( ( error : any ) = > console . log ( error ) ) ;
2017-01-20 16:00:05 -05:00
*
2017-01-20 21:56:16 +01:00
* NativeGeocoder . forwardGeocode ( "Berlin" )
2017-01-20 16:01:29 -05:00
* . then ( ( coordinates : NativeGeocoderForwardResult ) = > console . log ( "The coordinates are latitude=" + coordinates . latitude + " and longitude=" + coordinates . longitude ) )
2017-01-20 21:56:16 +01:00
* . catch ( ( error : any ) = > console . log ( error ) ) ;
* ` ` `
2017-01-20 16:00:05 -05:00
* @interfaces
2017-01-20 16:01:54 -05:00
* NativeGeocoderReverseResult
* NativeGeocoderForwardResult
2017-01-20 21:56:16 +01:00
* /
@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 > }
* /
2017-01-20 16:00:05 -05:00
@Cordova ( {
callbackOrder : 'reverse'
} )
2017-01-20 16:01:29 -05:00
static reverseGeocode ( latitude : number , longitude : number ) : Promise < NativeGeocoderReverseResult > { return ; }
2017-01-20 21:56:16 +01:00
/ * *
* Forward geocode a given address to find coordinates
* @param addressString { string } The address to be geocoded
* @return { Promise < any > }
* /
2017-01-20 16:00:05 -05:00
@Cordova ( {
callbackOrder : 'reverse'
} )
2017-01-20 16:01:29 -05:00
static forwardGeocode ( addressString : string ) : Promise < NativeGeocoderForwardResult > { return ; }
2017-01-20 21:56:16 +01:00
}
/ * *
* Encapsulates format information about a reverse geocoding result .
* /
2017-01-20 16:01:29 -05:00
export interface NativeGeocoderReverseResult {
2017-01-20 21:56:16 +01:00
/ * *
* 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 .
* /
2017-01-20 16:01:29 -05:00
export interface NativeGeocoderForwardResult {
2017-01-20 21:56:16 +01:00
/ * *
* The latitude .
* /
latitude : string ;
/ * *
* The longitude .
* /
longitude : string ;
}