Coder Social home page Coder Social logo

zrelyydereva / cordova-plugin-nativegeocoder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sebastianbaar/cordova-plugin-nativegeocoder

0.0 1.0 0.0 1 MB

Cordova plugin for native forward and reverse geocoding

License: MIT License

Java 51.45% Objective-C 0.30% Swift 45.43% JavaScript 2.82%

cordova-plugin-nativegeocoder's Introduction

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.

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 (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)

Result Object

https://developer.apple.com/documentation/corelocation/clplacemark https://developer.android.com/reference/android/location/Address.html

  • countryCode
  • postalCode
  • administrativeArea
  • subAdministrativeArea
  • locality
  • subLocality
  • thoroughfare
  • subThoroughfare

Example

nativegeocoder.reverseGeocode(success, failure, 52.5072095, 13.1452818);
function success(result) {
  alert("The address is: \n\n" + JSON.stringify(result));
}
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)

Result Object

  • latitude
  • longitude

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));
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.