1 | import { IonicNativePlugin } from '@ionic-native/core';
|
2 | /**
|
3 | * @name Native Geocoder
|
4 | * @description
|
5 | * Cordova plugin for native forward and reverse geocoding
|
6 | *
|
7 | * @usage
|
8 | * ```typescript
|
9 | * import { NativeGeocoder, NativeGeocoderResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder/ngx';
|
10 | *
|
11 | * constructor(private nativeGeocoder: NativeGeocoder) { }
|
12 | *
|
13 | * ...
|
14 | *
|
15 | * let options: NativeGeocoderOptions = {
|
16 | * useLocale: true,
|
17 | * maxResults: 5
|
18 | * };
|
19 | *
|
20 | * this.nativeGeocoder.reverseGeocode(52.5072095, 13.1452818, options)
|
21 | * .then((result: NativeGeocoderResult[]) => console.log(JSON.stringify(result[0])))
|
22 | * .catch((error: any) => console.log(error));
|
23 | *
|
24 | * this.nativeGeocoder.forwardGeocode('Berlin', options)
|
25 | * .then((result: NativeGeocoderResult[]) => console.log('The coordinates are latitude=' + result[0].latitude + ' and longitude=' + result[0].longitude))
|
26 | * .catch((error: any) => console.log(error));
|
27 | * ```
|
28 | * @interfaces
|
29 | * NativeGeocoderResult
|
30 | * NativeGeocoderOptions
|
31 | */
|
32 | export declare class NativeGeocoderOriginal extends IonicNativePlugin {
|
33 | /**
|
34 | * Reverse geocode a given latitude and longitude to find location address
|
35 | * @param latitude {number} The latitude
|
36 | * @param longitude {number} The longitude
|
37 | * @param options {NativeGeocoderOptions} The options
|
38 | * @return {Promise<NativeGeocoderResult[]>}
|
39 | */
|
40 | reverseGeocode(latitude: number, longitude: number, options?: NativeGeocoderOptions): Promise<NativeGeocoderResult[]>;
|
41 | /**
|
42 | * Forward geocode a given address to find coordinates
|
43 | * @param addressString {string} The address to be geocoded
|
44 | * @param options {NativeGeocoderOptions} The options
|
45 | * @return {Promise<NativeGeocoderResult[]>}
|
46 | */
|
47 | forwardGeocode(addressString: string, options?: NativeGeocoderOptions): Promise<NativeGeocoderResult[]>;
|
48 | }
|
49 | /**
|
50 | * Encapsulates format information about a geocoding result.
|
51 | * more Info:
|
52 | * - https://developer.apple.com/documentation/corelocation/clplacemark
|
53 | * - https://developer.android.com/reference/android/location/Address.html
|
54 | */
|
55 | export interface NativeGeocoderResult {
|
56 | /**
|
57 | * The latitude.
|
58 | */
|
59 | latitude: string;
|
60 | /**
|
61 | * The longitude.
|
62 | */
|
63 | longitude: string;
|
64 | /**
|
65 | * The country code.
|
66 | */
|
67 | countryCode: string;
|
68 | /**
|
69 | * The country name.
|
70 | */
|
71 | countryName: string;
|
72 | /**
|
73 | * The postal code.
|
74 | */
|
75 | postalCode: string;
|
76 | /**
|
77 | * The administrativeArea.
|
78 | */
|
79 | administrativeArea: string;
|
80 | /**
|
81 | * The subAdministrativeArea.
|
82 | */
|
83 | subAdministrativeArea: string;
|
84 | /**
|
85 | * The locality.
|
86 | */
|
87 | locality: string;
|
88 | /**
|
89 | * The subLocality.
|
90 | */
|
91 | subLocality: string;
|
92 | /**
|
93 | * The thoroughfare.
|
94 | */
|
95 | thoroughfare: string;
|
96 | /**
|
97 | * The subThoroughfare.
|
98 | */
|
99 | subThoroughfare: string;
|
100 | /**
|
101 | * The areasOfInterest
|
102 | */
|
103 | areasOfInterest: string[];
|
104 | }
|
105 | /**
|
106 | * Options for reverse and forward geocoding.
|
107 | */
|
108 | export interface NativeGeocoderOptions {
|
109 | /**
|
110 | * The locale to use when returning the address information.
|
111 | * If set to 'false' the locale will always be 'en_US'.
|
112 | * Default is 'true'
|
113 | */
|
114 | useLocale: boolean;
|
115 | /**
|
116 | * The default locale to use when returning the address information.
|
117 | * e.g.: 'fa-IR' or 'de_DE'.
|
118 | */
|
119 | defaultLocale?: string;
|
120 | /**
|
121 | * The maximum number of result to return (max is 5).
|
122 | * Default is 1
|
123 | */
|
124 | maxResults: number;
|
125 | }
|
126 |
|
127 | export declare const NativeGeocoder: NativeGeocoderOriginal; |
\ | No newline at end of file |