diff --git a/src/@ionic-native/plugins/native-geocoder/index.ts b/src/@ionic-native/plugins/native-geocoder/index.ts index 91f3edd8a..c60b76eb1 100644 --- a/src/@ionic-native/plugins/native-geocoder/index.ts +++ b/src/@ionic-native/plugins/native-geocoder/index.ts @@ -8,23 +8,29 @@ import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; * * @usage * ```typescript - * import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult } from '@ionic-native/native-geocoder'; + * import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder'; * * constructor(private nativeGeocoder: NativeGeocoder) { } * * ... * - * this.nativeGeocoder.reverseGeocode(52.5072095, 13.1452818) - * .then((result: NativeGeocoderReverseResult) => console.log(JSON.stringify(result))) + * let options: NativeGeocoderOptions = { + * useLocale: true, + * maxResults: 5 + * }; + * + * this.nativeGeocoder.reverseGeocode(52.5072095, 13.1452818, options) + * .then((result: NativeGeocoderReverseResult[]) => console.log(JSON.stringify(result[0]))) * .catch((error: any) => console.log(error)); * - * this.nativeGeocoder.forwardGeocode('Berlin') - * .then((coordinates: NativeGeocoderForwardResult) => console.log('The coordinates are latitude=' + coordinates.latitude + ' and longitude=' + coordinates.longitude)) + * this.nativeGeocoder.forwardGeocode('Berlin', options) + * .then((coordinates: NativeGeocoderForwardResult[]) => console.log('The coordinates are latitude=' + coordinates[0].latitude + ' and longitude=' + coordinates[0].longitude)) * .catch((error: any) => console.log(error)); * ``` * @interfaces * NativeGeocoderReverseResult * NativeGeocoderForwardResult + * NativeGeocoderOptions */ @Plugin({ pluginName: 'NativeGeocoder', @@ -40,22 +46,24 @@ export class NativeGeocoder extends IonicNativePlugin { * Reverse geocode a given latitude and longitude to find location address * @param latitude {number} The latitude * @param longitude {number} The longitude - * @return {Promise} + * @param options {NativeGeocoderOptions} The options + * @return {Promise} */ @Cordova({ callbackOrder: 'reverse' }) - reverseGeocode(latitude: number, longitude: number): Promise { return; } + reverseGeocode(latitude: number, longitude: number, options?: NativeGeocoderOptions): Promise { return; } /** * Forward geocode a given address to find coordinates * @param addressString {string} The address to be geocoded - * @return {Promise} + * @param options {NativeGeocoderOptions} The options + * @return {Promise} */ @Cordova({ callbackOrder: 'reverse' }) - forwardGeocode(addressString: string): Promise { return; } + forwardGeocode(addressString: string, options?: NativeGeocoderOptions): Promise { return; } } /** @@ -116,3 +124,25 @@ export interface NativeGeocoderForwardResult { */ longitude: string; } + +/** + * Options for reverse and forward geocoding. + */ +export interface NativeGeocoderOptions { + /** + * The locale to use when returning the address information. + * If set to 'false' the locale will always be 'en_US'. + * Default is 'true' + */ + useLocale: boolean; + /** + * The default locale to use when returning the address information. + * e.g.: 'fa-IR' or 'de_DE'. + */ + defaultLocale?: string; + /** + * The maximum number of result to return (max is 5). + * Default is 1 + */ + maxResults: number; +}