In new chrome (44.0.2403.157) geolocations doesnt

2019-01-18 12:55发布

问题:

Its seems like in new chrome version on MacOs on Linux Mint and on Windows geolocations doesnt works! Its returns error: "ERROR(2): Network location provider at 'https://www.googleapis.com/' : Returned error code 403."

Does anyone has same problem?

回答1:

Must be a bug in the latest version of Chrome, also happens in the page of Google Maps API: https://developers.google.com/maps/documentation/javascript/examples/map-geolocation

Hopefully it will be fixed fast.

Edited: Try now, it works :)



回答2:

Apparently this API has been forbidden access from insecure locations see here



回答3:

I filed a bug ticket here: https://productforums.google.com/forum/?utm_medium=email&utm_source=footer#!msg/chrome/q7B6gjCr1ps/Y9DEXPZ-_HYJ

Feel free to comment there, star it, etc.



回答4:

For future queries:

Starting with Chrome 50, Chrome no longer supports obtaining the user’s location using the HTML5 Geolocation API from pages delivered by non-secure connections. This means that the page that’s making the Geolocation API call must be served from a secure context such as HTTPS.

https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only?hl=en

This will break your web apps on chrome if you're not using HTTPS.



回答5:

i didn't get any solution for "Returned error code 403" but i found one solution to get current location if google api fails

 if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function (position) {
            current_location_lat = position.coords.latitude;
            current_location_lon = position.coords.longitude;
           }, function (error) {
//if error occurred by google api
              $.getJSON("http://ipinfo.io", function (ipinfo) {
                var latLong = ipinfo.loc.split(",");
                current_location_lat = latLong[0];
                current_location_lon = latLong[1];
                 });
            });

    } else {
        // Browser doesn't support Geolocation
        alert("Error: Your browser doesn\'t support geolocation");
    }