Skip to content

5uper/cordova-plugin-nativegeocoder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova NativeGeocoder plugin

Call nativegeocoder.reverseGeocode() to transform a latitude and longitude into an address or nativegeocoder.forwardGeocode() to transform an address into a latitude and longitude using iOS CoreLocation service and Android Geocoder class.

No need for creating API keys or querying external APIs

Installation

cordova plugin add cordova-plugin-nativegeocoder

The iOS part is written in Swift 3 and the Swift support plugin is configured as a dependency.

Ionic Native Demo

Have a look at the demo project for a working demo with the Ionic Framework and Ionic Native.

Supported Platforms

  • iOS
  • Android (works only on native devices)

Methods

  • nativegeocoder.reverseGeocode
  • nativegeocoder.forwardGeocode

nativegeocoder.reverseGeocode

Reverse geocode a given latitude and longitude to find location address.

nativegeocoder.reverseGeocode(successCallback, errorCallback, latitude, longitude);

Parameters

  • latitude: The latitude. (Double)
  • longitude: The longtitude. (Double)

Example

nativegeocoder.reverseGeocode(success, failure, 52.5072095, 13.1452818);
function success(result) {
  alert("The address is: \n\n" + result.street + " " + result.houseNumber + ", " + result.postalCode + " " + result.city + " " + result.district + " in " + result.countryName + " - " + result.countryCode);
}
function failure(err) {
  alert(JSON.stringify(err));
}

nativegeocoder.forwardGeocode

Forward geocode a given address to find coordinates.

nativegeocoder.forwardGeocode(successCallback, errorCallback, addressString);

Parameters

  • addressString: The address to be geocoded. (String)

Example

nativegeocoder.forwardGeocode(success, failure, "Berlin");
function success(coordinates) {
  alert("The coordinates are latitude = " + coordinates.latitude + " and longitude = " + coordinates.longitude);
}
function failure(err) {
  alert(JSON.stringify(err));
}

About

Cordova plugin for native forward and reverse geocoding

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 25.2%
  • Swift 20.9%
  • TypeScript 20.5%
  • CSS 14.9%
  • HTML 12.4%
  • JavaScript 5.9%
  • Objective-C 0.2%