npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-nativegeocoder

v3.5.1

Published

Cordova plugin for native forward and reverse geocoding

Downloads

11,674

Readme

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

Please read Known Issues before posting an issue! Thank you! :heart_eyes:

Ionic

This plugin is also available for Ionic awesome-cordova-plugins & Capacitor.

Installation

cordova plugin add cordova-plugin-nativegeocoder

For iOS Cordova iOS version >5.0.0 is required.

Configuration

You can also configure the following variable to customize the iOS location plist entry

  • LOCATION_WHEN_IN_USE_DESCRIPTION for NSLocationWhenInUseUsageDescription (defaults to "Use geocoder service")

Supported Platforms

  • iOS
  • Android

API

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

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

Parameters

| Parameter | Type | Default | Description | | ---------------- | ---------- | ------- | ------------------------------------------------------------- | | success | Function | | Success callback (with Array) | | error | Function | | Error callback. | | latitude | Number | | The latitude. | | longitude | Number | | The longtitude. | | options | Object | | Optional. Is called when the api encounters an error while initializing the context. |

All available options attributes:

| Attribute | Type | Default | Comment | | ------------------------------ | -------- | ------------------------------------------------------------ | -------------------------------------------------- | | useLocale | Boolean | true | Optional. Only works for Android and iOS 11.0+. | | defaultLocale | String | | Optional. E.g.: 'fa-IR' or 'de_DE'; works only for Android and iOS 11.0+. | | maxResults | Number | 1 | Optional. Min value: 1, max value: 5. |

Array

Conforms to Apple's and Android's geocoder's result arrays.

| Value | Type | |-------------|----------- | latitude | String | | longitude | String | | countryCode | String | | postalCode | String | | administrativeArea | String | | subAdministrativeArea | String | | locality | String | | subLocality | String | | thoroughfare | String | | subThoroughfare | String | | areasOfInterest | Array<String> | | addressLines (Android only) | Array<String> |

Example

nativegeocoder.reverseGeocode(success, failure, 52.5072095, 13.1452818, { useLocale: true, maxResults: 1 });

function success(result) {
  var firstResult = result[0];
  console.log("First Result: " + JSON.stringify(firstResult));
}

function failure(err) {
  console.log(err);
}

.forwardGeocode(success, error, addressString, options)

Forward geocode a given address to find coordinates.

Parameters

| Parameter | Type | Default | Description | | ---------------- | ---------- | ------- | ------------------------------------------------------------- | | success | Function | | Success callback (with Array) | | error | Function | | Error callback. | | addressString | String | | The address to be geocoded. | | options | Object | | Optional. Is called when the api encounters an error while initializing the context. |

All available options attributes:

| Attribute | Type | Default | Comment | | ------------------------------ | -------- | ------------------------------------------------------------ | -------------------------------------------------- | | useLocale | Boolean | true | Optional. Only works for Android and iOS 11.0+. | | defaultLocale | String | | Optional. E.g.: 'fa-IR' or 'de_DE'; works only for Android and iOS 11.0+. | | maxResults | Number | 1 | Optional. Min value: 1, max value: 5. |

Array

Conforms to Apple's and Android's geocoder's result arrays.

| Value | Type | |-------------|----------- | latitude | String | | longitude | String | | countryCode | String | | postalCode | String | | administrativeArea | String | | subAdministrativeArea | String | | locality | String | | subLocality | String | | thoroughfare | String | | subThoroughfare | String | | areasOfInterest | Array<String> | | addressLines (Android only) | Array<String> |

Example

nativegeocoder.forwardGeocode(success, failure, "Berlin", { useLocale: true, maxResults: 1 });

function success(coordinates) {
  var firstResult = coordinates[0];
  console.log("The coordinates are latitude = " + firstResult.latitude + " and longitude = " + firstResult.longitude);
}

function failure(err) {
  console.log(err);
}

Known Issues

Android

Geocoder not working

Errors like Geocoder:getFromLocationName Error: grpc failed, Geocoder is not present on this device/emulator., Geocoder [...] Error or Geocoder Service not available.

Why?: The plugin checks for Geocoder.isPresent() (Android docs). One reason for Geocoder not working on a device could be that you are running your app on an emulator or on a device without Google Play Services. But Geocoder API "[...] requires a backend service that is not included in the core android framework".

Any workaround?: Yes, install Google Play services. Open SDK Tools > Tab SDK Tools > install Google Play services.

iOS

...

Thank you :heart:

Yes you! Thank you very much for using cordova-plugin-nativegeocoder. If you have any feedback or run into issues using the plugin, please file an issue on this repository.