Coder Social home page Coder Social logo

sebastianbaar / cordova-plugin-nativegeocoder Goto Github PK

View Code? Open in Web Editor NEW
60.0 5.0 32.0 1.04 MB

Cordova plugin for native forward and reverse geocoding

License: MIT License

Java 49.15% Swift 46.36% JavaScript 4.49%
cordova-plugin cordova-android cordova-android-plugin cordova-ios cordova-ios-plugin geocoder ios android swift reversegeocode

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

Please read Known Issues before posting an issue! Thank you! 😍

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 ❤️

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.

cordova-plugin-nativegeocoder's People

Contributors

davidwiesner avatar sebastianbaar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cordova-plugin-nativegeocoder's Issues

Error when finding position

During my approval of an App for the AppStore I hit a bug, that puzzles me a lot.

The Apple headquarter is located at: Apple Infinite Loop, 1 Infinite Loop, Cupertino, Californien, USA

On Android I get the location 37.3316756, -122.030189 but on iPhone I get the error message: "Cannot get a location"

If I search for: "Apple, Infinite Loop, Cupertino, Californien, USA" or "Apple, 1 Infinite Loop, Cupertino, Californien, USA" it works fine on both platforms.

I am using Google Places to find the address, when the user enters the address.

Using maps.google.com the address results in this:
image

Plugin overwrites plist entry for NSLocationWhenInUseUsageDescription

Since a hardcoded string is set in the plugin.xml file for NSLocationWhenInUseUsageDescription, the value that comes from other plugins that use variables instead is overwritten with the string "Using geocoder service" which cannot be changed.

The right way to implement this would be something like:

       <preference name="GEOLOCATION_USAGE_DESCRIPTION" default=" " />
        <config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
            <string>$GEOLOCATION_USAGE_DESCRIPTION</string>
        </config-file>

IOS13 -> Don´t show Streetname

Hello
i have download the new iOS 13 to build the a new Version from the App. And i see that the thoroughfare not shown anymore.

Can you check this?

Thx

hit limit

I just wanted to know, is there any hits limit? Like if we use google api to get location details, we used to have some hits limit if the account is not paid. After exceeding the hits quota we cant call the goole api to get address.

forward geocoding returns different lat long based on devices.

Hi , i was working in geocoding and getting lat long for an address or zipcode which is being entered by the user, when i was testing with 10004 zipcode, which is near newyork, we are getting different lat long for different devices example : samsung galaxy s7 returns lat : 40.705478 long : -74.015044 where as in lenovo k4 note returns lat : 48.586179 long : 4.107207 . I don't know why it is returning different lat long for same zipcode . Can you please help me on this.

I'm trying to import NativeGeocoder in the app.module of my project. But I get this error

Type 'NativeGeocorderOriginal' is not assignable to type 'Provider'
Type 'NativeGeocoderOriginal' is missing the following properties from type ''FactoryProvider: provide, useFactory

This is my code
`import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

import { NativeGeocoder } from '@ionic-native/native-geocoder';

@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
NativeGeocoder,
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}`

I would really appreciated, if you guys could help me.

bug(android): Geocoding is blocking the main thread

Describe the bug
While running an reverse/forward geocoding the main thread is blocked by up to 4 seconds

To Reproduce
Steps to reproduce the behavior:

  1. Open LogCat from AndroidStudio
  2. Run e.g.: reverseGeocode on a low internet connection.
  3. App hangs on transitions or user interaction while reverseGeocode is running
  4. See Log message like this:
THREAD WARNING: exec() call to NativeGeocoder.reverseGeocode blocked the main thread for 3639ms. Plugin should use CordovaInterface.getThreadPool()

Expected behavior
The reverse/forward geocoding should run in a background thread without blocking the ui.

Plugin Version
v3.2.2

Smartphone (please complete the following information):

  • Device: Pixel 2
  • OS: Android 9

Additional context
There are some suggestion how to resolve this issue:

Ionic Native Geocoder “Cannot find a location.”

While searching for coordinates, i.e. forwardGeocoding, the plugin is returning "Cannot find a location."

This is the method in my provider -
//This calls the Native geocoder and returns the geocoordinates. getGeoCode(address: string): Promise<any> { console.log('The address key is - ' + address); return new Promise((resolve, reject) => { this.nativeGeocoder.forwardGeocode(address) .then((nativegeocoordinates: NativeGeocoderForwardResult) => { console.log('The coordinates are - ' + JSON.stringify(nativegeocoordinates)); let addressCoordinates: DeliveryAddressCoordinates = nativegeocoordinates; resolve(addressCoordinates); }) .catch((error: any) => { console.log(JSON.stringify(error)); reject(error); }); }) }

The method accepts an address string as input. So I get the address from google places API, and pass the description here.

Now, for certain addresses, it just doesn't seem to find the coordinates, and returns a "Cannot find a location" message. For e.g. "Bhadra Brookefields Apartment B Block, Kundanahalli Lake Road, Kundalahalli, Brookefield, Bengaluru, Karnataka, India" is a valid address and returns the coordinates, while "Times Square 42 Street Station, New York, NY, USA" does not find a match and returns a message saying - "Cannot find a location".

The "Cannot find a location" seems to be originating from the code here on line #182, where it is referencing the Android class.

Is this a known issue? Or is there something that I am doing wrong?

Error: [$injector:unpr] Unknown provider: NativeGeocoderProvider

Hello, i install this package, when i am going to use it, it gives me "Error: [$injector:unpr] Unknown provider: NativeGeocoderProvider " error.

Below is my code .
function Search1Controller($log, header, DialogService, $auth, $localStorage, $state, $rootScope, $scope, API, mapbox, geo, $document, $interval, $timeout, broadcast, toast, $cordovaGeolocation, NativeGeocoder) {

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

Getting wrong lat long

I am developing a hybrid mobile app in ionic2. I want to get lat-long base on the address.
Following is my code:

this.nativeGeocoder.forwardGeocode('20 Greenway Rockville Centre NY 11570') .then((coordinates: NativeGeocoderForwardResult) => console.log('The coordinates are latitude=' + coordinates.latitude + ' and longitude=' + coordinates.longitude)) .catch((error: any) => console.log(error));

On ios, i am getting latitude = 40.661109 and longitude=-73.626429 which is wrong. The correct lat-long is latitude = 40.660858 and longitude=73.626354.

What could be the issue?

iOS build error

Hey, I'am trying to build to iOS but Im getting these errors.

Using Swift 1.7.1.

`Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:5:48: warning: extraneous '_' in parameter: 'command' has no keyword argument name
    @objc(reverseGeocode:) func reverseGeocode(_ command: CDVInvokedUrlCommand) {
                                               ^~
                                               
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:80:45: warning: extraneous '_' in parameter: 'command' has no keyword argument name
  @objc(forwardGeocode:)func forwardGeocode(_ command: CDVInvokedUrlCommand) {
                                            ^~
                                            
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:24:52: error: value of type 'CLPlacemark' has no member 'isoCountryCode'
                        resultObj["countryCode"] = placemark.isoCountryCode ?? ""
                                                   ^~~~~~~~~ ~~~~~~~~~~~~~~
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:34:55: error: incorrect argument label in call (have 'status:messageAs:', expected 'status:messageAsDictionary:')
                        pluginResult = CDVPluginResult(
                                                      ^
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:42:55: error: incorrect argument label in call (have 'status:messageAs:', expected 'status:messageAsString:')
                        pluginResult = CDVPluginResult(
                                                      ^
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:51:51: error: incorrect argument label in call (have 'status:messageAs:', expected 'status:messageAsString:')
                    pluginResult = CDVPluginResult(
                                                  ^
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:58:37: error: value of type 'CDVCommandDelegate' has no member 'send'
                self.commandDelegate!.send(
                ~~~~~~~~~~~~~~~~~~~~^ ~~~~
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:67:43: error: incorrect argument label in call (have 'status:messageAs:', expected 'status:messageAsString:')
            pluginResult = CDVPluginResult(
                                          ^
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:72:33: error: value of type 'CDVCommandDelegate' has no member 'send'
            self.commandDelegate!.send(
            ~~~~~~~~~~~~~~~~~~~~^ ~~~~
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:101:55: error: incorrect argument label in call (have 'status:messageAs:', expected 'status:messageAsDictionary:')
                        pluginResult = CDVPluginResult(
                                                      ^
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:108:55: error: incorrect argument label in call (have 'status:messageAs:', expected 'status:messageAsString:')
                        pluginResult = CDVPluginResult(
                                                      ^
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:117:51: error: incorrect argument label in call (have 'status:messageAs:', expected 'status:messageAsString:')
                    pluginResult = CDVPluginResult(
                                                  ^
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:126:47: error: incorrect argument label in call (have 'status:messageAs:', expected 'status:messageAsString:')
                pluginResult = CDVPluginResult(
                                              ^
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:133:33: error: value of type 'CDVCommandDelegate' has no member 'send'
            self.commandDelegate!.send(
            ~~~~~~~~~~~~~~~~~~~~^ ~~~~
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:143:39: error: incorrect argument label in call (have 'status:messageAs:', expected 'status:messageAsString:')
        pluginResult = CDVPluginResult(
                                      ^
/Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift:148:29: error: value of type 'CDVCommandDelegate' has no member 'send'
        self.commandDelegate!.send(
        ~~~~~~~~~~~~~~~~~~~~^ ~~~~

** BUILD FAILED **


The following build commands failed:
	CompileSwift normal x86_64 /Users/Me/app-ios/platforms/ios/appName/Plugins/cordova-plugin-nativegeocoder/NativeGeocoder.swift
	CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/Me/app-ios/platforms/ios/cordova/build-debug.xcconfig,-workspace,appName.xcworkspace,-scheme,appName,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,name=iPhone 6s Plus,build,CONFIGURATION_BUILD_DIR=/Users/Me/app-ios/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/Me/app-ios/platforms/ios/build/sharedpch

[ERROR] An error occurred while running cordova build ios (exit code 1).`

Im guessing it has something to do with swift, however I do not know how to fix this so I might aswell just post it here...

IOS runtime error - CLGeocoder:geocodeAddressString Error

The plugin is working very well on Android, but I am having a weird problem on IOS and it is a runtime problem and not a build problem, I am getting an error on Xcode console saying:

CLGeocoder:geocodeAddressString Error

And it is not working

Plugin Version
v3.1.0

Smartphone:
Tested on iPhone 6

Plugin not available in ionic-native

I have tried this plugin in my demo app. Its giving me following error on build.

/node_modules/ionic-native/dist/es5/index"' has no exported member 'NativeGeocoder', 'NativeGeocoderReverseResult', 'NativeGeocoderForwardResult'.

ionic-native version: 2.2.11

Failed to fetch plugin cordova-plugin-nativegeocoder via registry

When I run the command ionic cordova plugin add cordova-plugin-nativegeocoder, I get the following error:

Failed to fetch plugin cordova-plugin-nativegeocoder via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! Cannot read property 'match' of undefined

ionic-angular: v3.6.1

missing command error

I use this code but it shows above error

this.nativeGeocoder.reverseGeocode(this.letitude, this.longitude, options)
.then((result: NativeGeocoderReverseResult[]) =>{
console.log(result);
console.log(JSON.stringify(result[0]));

Can I get the address value only in English?

I have noticed that the address return value is in the language of phone setting.
Is there any way I can set the language option only in English no matter what the phone setting is?

Return Address Line or formatted address

Is your feature request related to a problem? Please describe.
A simple but kind of required feature is to return, along with current Address class values, the value of addressLine which in web API is similar to formatted_address, as creating the address string is sometimes both overhead and improper.

Describe the solution you'd like
Just start returning the addressLine in the current response.

Describe alternatives you've considered
We now have to construct own address which is not as good and helpful for users. The "unnamed road" and other such keywords irritates users.

reverseGeocode's NativeGeocoderReverseResult is incomplete

The response to the reverseGeocode function is incomplete and does not return the fields thoroughfare and subThoroughfare

This is my code:
this.nativeGeocoder.reverseGeocode(position.coords.latitude, position.coords.longitude, { useLocale: true, maxResults: 1 }) .then((result: NativeGeocoderReverseResult[]) => { console.log(JSON.stringify(result)); }) .catch((error: any) => console.log(error));

the previous code only returns:
[{"countryCode":"ES","countryName":"España","postalCode":"08013","locality":"Barcelona","subLocality":"Barcelona"}]

License is missing

Could you please add a license file to this repo? Currently it's unclear what are the terms and conditions of using NativeGeocoder plugin code.

Many thanks in advance!

Hangs on build

I've been building an Ionic/Cordova app with a lot of success but now that I've added this plugin everytime I run "Cordova run ios" it now takes 5 minutes instead of 15 seconds to build the app.

It seems to hang at the line "NativeGeocoder.o".

What is it doing that whole time? Feels like it's downloading something heavy... How do I resolve this as it's now becoming a massive time constraint while working on other features. Plus to make matters worse the device times out and locks so half the time I have to re-run the 5 minute build simply based on a permission issue.

Sorry for such a "petty" issue but I've googled to no avail. No other package has caused this issue.

return multiple locations?

Is it possible to return the list of locations instead of just one?
e.g. I reckon typing in something ambiguous like 'depot' would yield many possible results? since Android geocoder api states that they return a list.

thanks!

Forward geocoding to return location name and type

The forward geocoding function returns an array of latitude, longitude values. This is not enough for my application, because the user reasonably needs the names of the locations returned to choose from. The formatted_address value of the geocoding service is good to have because the user may not type in a full address (ex. 'Philadelph', so the app cannot rely on the user input later on to identify/label this location. The type of the location returned is also interesting and would be nice to have it.

In the google geocoding service, the values requested here are:
types[]: string,
formatted_address: string,

See also:
https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes
https://developers.google.com/maps/documentation/geocoding/intro

Thank you for the great package!

Cordova 9 support: Update cordova-plugin-add-swift-support to 2.0.2

Describe the bug
The cordova-plugin-add-swift-support 1.7.2 does not support cordova 9. Instaling your plugin in a cordova 9 project theirfore result in this error:
Using "requireCordovaModule" to load non-cordova module "glob" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.

To Reproduce
Steps to reproduce the behavior:

  1. create a cordova 9 project
  2. add your plugin
  3. See error
    Using "requireCordovaModule" to load non-cordova module "glob" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.

Expected behavior
Should work also for cordova 9

Plugin Version
v3.2.1

Smartphone (please complete the following information):

  • Device: ios
  • OS: ios

Android logs error when it shouldn't

Describe the bug
When calling reverseGeocode with null options, it prints this error stacktrace:

W/System.err: org.json.JSONException: Value null at 2 of type org.json.JSONObject$1 cannot be converted to JSONObject
        at org.json.JSON.typeMismatch(JSON.java:100)
        at org.json.JSONArray.getJSONObject(JSONArray.java:525)
        at cordova.plugin.nativegeocoder.NativeGeocoder.execute(NativeGeocoder.java:43)
W/System.err:     at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
        at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
        at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
        at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:325)
        at android.os.Looper.loop(Looper.java:142)
        at android.os.HandlerThread.run(HandlerThread.java:65)

But it otherwise works fine. It doesn't seem like that should be printed. It's ok to pass null options.

To Reproduce
Call reverseGeocode with null options

Expected behavior
No error logging

Plugin Version
latest

Smartphone (please complete the following information):
Any

Additional context
None

Offline Support

Is there a way on this plugin to work offline(without internet but enabled location) ?

Geocoder does not work

I tried to add nativegeocoder in my Ionic App and executed the reverseGeocode function. In the browser, it showed that cordova is not available. Then I run my app in android device, it showed that Geocoder is not present on this device/emulator. How can I fix this problem?

this.nativeGeocoder.reverseGeocode return error -- > "CLGeocoder:reverseGeocodeLocation Error" on ios12 platform

Hi guys!
I get an error when trying to geocoding the coordinates on iOS1. Before updating the OS, everything was ok. Android also works without problems. Perhaps you can tell the reason?

this.nativeGeocoder.reverseGeocode(coordinates.lat, coordinates.long, options) .then((result: NativeGeocoderReverseResult[]) => { console.log(result[0]); }) .catch((error: any) => { console.log('reverseGeocodeErr', error); });

Cordova geocoder stops working

I started using cordova geocoder in my project. In my first attempts to use it, it wasn't working, falling into the catch exception. And in a day, out of nothing, it started to work, returning me the adress. And, now, a few days later, it stopped working again. Is there any problem with its service? Because I'm sure I haven't changed my code so it stop working.

reverseGeocode Error. Help me. Please

When execute the following code, fall into failure function, and alert: "CLGecoder:reverseGeocodeLocation Error".

nativegeocoder.reverseGeocode(success, failure, 30.649908, 104.014556);
function success(result) {
alert("The address is: \n\n" + JSON.stringify(result));
}
function failure(err) {
alert(JSON.stringify(err));
}

How to fix the problem? Help me. Please.

Plugin needs to be updated to Swift 3

XCode 8 can no longer compile apps that use an older version of Swift. The automatic converting feature of XCode seem to work fine, the build did not throw any errors afterwards. But I haven't tested the plugin yet.

reverseGeocode Error: grpc failed

I am getting "Geocoder:getFromLocationName Error: grpc failed" while using reverseGeocode.

It works after i switch on flight mode and wait for 10 seconds before switching it off again.

Any idea? Is there any fix or workaround for this?

Cannot get an address.

Hello,
I tried to use plugin ionic 3

this.nativeGeocoder.reverseGeocode ==== i got this error ("Cannot get an address.")
this.nativeGeocoder.forwardGeocode ==== i got this error Cannot find a location.

and that my page

`import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, Platform } from 'ionic-angular';
import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder';

@IonicPage()
@Component({
  selector: 'page-test',
  templateUrl: 'test.html',
})
export class TestPage {

  constructor(public navCtrl: NavController,private platform:Platform , public navParams: NavParams,private nativeGeocoder: NativeGeocoder) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad TestPage');

      if (this.platform.ready())
      {
        this.loadAddress();
      }
  }


  loadAddress()
{
  let options: NativeGeocoderOptions = {
    useLocale: true,
    maxResults: 5
};

this.nativeGeocoder.reverseGeocode(52.5072095, 13.1452818, options)
  .then((result: NativeGeocoderReverseResult[]) => console.log(JSON.stringify(result[0])))
  .catch((error: any) => console.log(error));

this.nativeGeocoder.forwardGeocode('Berlin', options)
  .then((coordinates: NativeGeocoderForwardResult[]) => console.log('The coordinates are latitude=' + coordinates[0].latitude + ' and longitude=' + coordinates[0].longitude))
  .catch((error: any) => console.log(error));
}
}
`

thanks

TypeError: Object(...) is not a function

I'm getting an TypeError: Object(...) is not a function error when trying to use Native Geocoder.

Code is below:

import { NativeGeocoder, NativeGeocoderOptions, NativeGeocoderReverseResult, NativeGeocoderForwardResult } from '@ionic-native/native-geocoder'; constructor(private Platform: Platform, public loadingCtrl: LoadingController, private router: Router, public natGeo: NativeGeocoder) {}
... let options: NativeGeocoderOptions = { useLocale: true, maxResults: 5 };

this.natGeo.forwardGeocode('Berlin', options) .then((coordinates: NativeGeocoderForwardResult[]) => console.log('The coordinates are latitude=' + coordinates[0].latitude + ' and longitude=' + coordinates[0].longitude)) .catch((error: any) => console.log(error)); ...

How can I get this to work please?

grpc failed error

  I am getting grpc failed error while using **forward geocoder** most of the time. 

 Kindly help to resolve this.

Let the user select locale

Hi
I really loved this plugin. Thanks for great job.
It would be very helpful if you let the use select locale. I mean in addition to useLocale add an option parameter which is a string and accepts locales like "en-US" or "fa-IR", ...
Thanks

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.