Geolocation - PositionError: Returned error code 400


#1

Going by this https://ionicframework.com/docs/native/geolocation/

Trying this in browser:

 this.platform.ready().then(() => {
      console.log('platform is ready');
      this.geolocation.getCurrentPosition().then(pos => {
        console.log('lat: ' + pos.coords.latitude + ', lon: ' + pos.coords.longitude);
      }).catch((error) => {
        console.log('Error getting location', error);
      });
    });

I allow to use my location but get the following error:
PositionError {code: 2, message: "Network location provider at 'https://www.googleapis.com/' : Returned error code 400."}

Setting the geolocation manually fixes the problem:


#2

What platform are you testing on and receiving this error?
Did you check network traffic on what URLs are called and what they respond?


#3

I have the same problem… Nothing since I upgrade to new ionic native…


#4

I have the same problem when trying to debug my app via VS Code - Cordova Tools Extension with option “Serve to the browser (ionic serve)”.

Any news here?


#5

Can you try with another browser like Safari or Firefox?


#6

I had the same issue, solved by changing the browser to firefox…
I was using Chrome - Version 60.0.3112.90 (Official Build), was not working.


#7

I’m also getting the same error on Chrome - Version 60.0.3112.113 (Official Build)


#8

Updated to Version 61.0.3163.91 (Official Build) and I’m not seeing the error anymore


#9

Any news?
Same with me on chrome in windows 10.

polyfills.js:3 Unhandled Promise rejection: PositionError {code: 2, message: “Network location provider at ‘https://www.googleapis.com/’ : Returned error code 400.”}code: 2message: "Network location provider at ‘https://www.googleapis.com/’ : Returned error code 400."proto: PositionError ; Zone: ; Task: Promise.then ; Value: PositionError {code: 2, message: “Network location provider at ‘https://www.googleapis.com/’ : Returned error code 400.”} undefined


#10

Nope, sorry. haven’t been working on this recently.