Native Geocoder
Cordova plugin for native forward and reverse geocoding
Repo: https://github.com/sebastianbaar/cordova-plugin-nativegeocoder
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-nativegeocoder $ npm install --save @ionic-native/native-geocoder
- Add this plugin to your app's module
Supported platforms
- iOS
- Android
Usage
import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult } from '@ionic-native/native-geocoder';
constructor(private nativeGeocoder: NativeGeocoder) { }
...
this.nativeGeocoder.reverseGeocode(52.5072095, 13.1452818)
.then((result: NativeGeocoderReverseResult) => console.log(JSON.stringify(result)))
.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))
.catch((error: any) => console.log(error));
Instance Members
reverseGeocode(latitude, longitude)
Reverse geocode a given latitude and longitude to find location address
Param | Type | Details |
---|---|---|
latitude |
number
|
The latitude |
longitude |
number
|
The longitude |
Returns: Promise<NativeGeocoderReverseResult>
forwardGeocode(addressString)
Forward geocode a given address to find coordinates
Param | Type | Details |
---|---|---|
addressString |
string
|
The address to be geocoded |
Returns: Promise<NativeGeocoderForwardResult>
NativeGeocoderReverseResult
Param | Type | Details |
---|---|---|
countryCode |
string
|
The country code. |
countryName |
string
|
The country name. |
postalCode |
string
|
The postal code. |
administrativeArea |
string
|
The administrativeArea. |
subAdministrativeArea |
string
|
The subAdministrativeArea. |
locality |
string
|
The locality. |
subLocality |
string
|
The subLocality. |
thoroughfare |
string
|
The thoroughfare. |
subThoroughfare |
string
|
The subThoroughfare. |
NativeGeocoderForwardResult
Param | Type | Details |
---|---|---|
latitude |
string
|
The latitude. |
longitude |
string
|
The longitude. |