I know, this problem has already been reported in the past.
But it was solved in 2015. Now it's back in 2017!
The Error (Geolocation Position Error, Code 2) appears in Chrome (Version 56.0.2924.87 (64-bit)):
Network location provider at 'https://www.googleapis.com/' : Returned error code 403.
Error Code 2
Please Note: Chrome needs HTTPS for Geolocation!
function getCoords() {
return new Promise(function(resolve, reject) {
if (navigator.permissions) {
navigator.permissions.query({
name: 'geolocation'
}).then(function(permission) {
switch (permission.state) {
case 'granted':
navigator.geolocation.getCurrentPosition(function(pos) {
resolve(pos.coords);
}, function(error) {
console.error('Error Code: ' + error.code + ' - ' + error.message);
});
break;
case 'prompt':
console.info('Check Geolocation Promt.');
navigator.geolocation.getCurrentPosition(function(pos) {
resolve(pos.coords);
}, function(error) {
console.error('Error Code: ' + error.code + ' - ' + error.message);
});
break;
case 'denied':
default:
resolve(null);
break;
}
});
} else {
reject(new DOMError('NotImplemented', 'Permission API is not supported'));
}
});
}
function locate() {
if (typeof Promise !== "undefined" && Promise.toString().indexOf("[native code]") !== -1) {
getCoords().then(function(coords) {
if (coords !== null) {
console.log(coords);
document.getElementById('coords').value = coords.latitude + ', ' + coords.longitude;
} else {
console.warn('No coords returned :/');
}
});
} else {
console.warn('This browser doesn\'t support geolocation.');
}
}
<button onclick="javascript:locate()">Locate me</button>
<input type="text" id="coords" readonly/>
The problem seems to be the same in this Google Maps API example: https://developers.google.com/maps/documentation/javascript/examples/map-geolocation
I know the subject contains Google Chrome, but this error:
Network location provider at 'https://www.googleapis.com/' : No response received.
happens also on Chromium, version 70.0.3538.67 (Developer Build) (64-bit) (macOS, High Sierra).
Maybe this https://bugs.chromium.org/p/chromium/issues/detail?id=820945&can=2&start=0&num=100&q=geolocation&colspec=ID is related.
This happened to me too, spent 30 minz trying to find a solution only to then try restarting
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With