Cordova-plugin-googlemaps: Empty Geocode result

Created on 16 Jul 2017  路  22Comments  路  Source: mapsplugin/cordova-plugin-googlemaps

  • What is your question, problem or request?
    The geocode is returning nothing at all

  • What version of this plugin do you use? Please including miner version ($> cordova plugin list)
    2.0

  • Code, Data or Error log (please format your code or data)

constructor(
    ...
    private geolocation: Geolocation,
    private gecoder: Geocoder,
    ...
  ) {}

getGeocode() {
     let request: GeocoderRequest = {
        position: new LatLng(position.coords.latitude, position.coords.longitude),
     };

     this.gecoder.geocode(request).then((results: GeocoderResult) => {
        console.log(results); // Returns absolutely nothing
     });
}

Most helpful comment

After reinstall the plugin, restart my device and change the wifi network.. its working :)

All 22 comments

It seems you use the v2 plugin with ionic wrapper, but the ionic wrapper does not support the plugin v2 yet.

You need to write your code WITHOUT the ionic wrapper.

https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/v2.0.0/For-ionic2-users/README.md

I tried this before I tried the ionic wrapper and it still failed with this

      plugin.google.maps.Geocoder.geocode({
        "position": {"lat": 43.031873, "lng": -71.073203}
      }, function(results) {

        if (results.length === 0) {
          // Not found
          console.log('NOT FOUND');
          return;
        }

        console.log(results[0]);
      });

Since this plugin just returns the results of native APIs. No results means Google can not find answer or your app is blocked.

How can I know if I'm blocked?

@thpoiani Honestly, you should take a look at your design. I ended up pushing this geocoding to the server since I was getting lat and lng from the native geolocation package anyway. The support for doing this on the device ended up not making sense for our app.

@steveacalabro In my scenario, we want to do this on the device but we are getting empty results :(

Unfortunately, this plugin just make a request to Google or Apple through the native APIs. If you get empty result, I can not do anything.

@wf9a5m75 Can I check my API KEY?

What do you mean?

@thpoiani Another person on my team did get a proof of concept working with the code from that ionic2 notes page and setting up the correct app enabled on google. I think it ended up being a strange enabled api, I would find out which maps one it was and try that

I think its one of the following. Don't know for sure since he is not here.

This plugin needs just Google Maps SDK for iOS and Google Maps Android API v2

@wf9a5m75 Can I check if the KEY API was added to the plugin?
Maybe that's could be the problem.

I'm trying to run this code but I got no results

plugin.google.maps.Geocoder.geocode({'position': {lat:-21.80273646969314,lng:-48.1786909326911}}, console.log)

cordova-plugin-googlemaps 2.0.0-beta2-20170731-1540 "cordova-plugin-googlemaps"

plugin.google.maps.Geocoder.geocode({
  'position': {lat:-21.80273646969314,lng:-48.1786909326911}
}, function(result) {
 console.log(result);
});

@wf9a5m75 empty too :disappointed:

Are you testing on Android or iOS?

Android

plugin.google.maps.Geocoder.geocode({'position': {lat:-21.80273646969314,lng:-48.1786909326911}}, function(results) {

console.log(results);
});

screen shot 2017-08-02 at 5 21 30 pm

Plugin works fine.

I will try to reinstall the plugin

You can use this plugin also.
https://ionicframework.com/docs/native/native-geocoder/

I checked the code, and code is almost the same.

After reinstall the plugin, restart my device and change the wifi network.. its working :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TimothyFehr picture TimothyFehr  路  5Comments

splitice picture splitice  路  5Comments

wf9a5m75 picture wf9a5m75  路  3Comments

wf9a5m75 picture wf9a5m75  路  5Comments

rosnaib11 picture rosnaib11  路  5Comments