I'm requesting for the user's geolocation via navigator.geolocation
, but I'm getting thrown the error:
Network location provider at 'https://www.googleapis.com/' : Returned error code 400.
This error occurs on Chrome 54.0.2840.98. This works without issues fine on Firefox 50.0. I'm running a local server with http-server
Here's the function:
_getLocation: function() {
if (!navigator.geolocation) {
alert('Geolocation is not supported by this browser, maybe use a pop-up and ask user for zipcode?');
}
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
this.setState({
location: {
latitude: latitude,
longitude: longitude
}
});
this._getWeather(this.state.location.latitude, this.state.location.longitude);
}
function error(err) {
console.warn('ERROR(' + err.code + '): ' + err.message);
this.setState({
location: 'ERROR(' + err.code + '): ' + err.message
});
}
navigator.geolocation.getCurrentPosition(success.bind(this), error.bind(this));
},
I don't know the answer but I noticed this... I use http-server -o at the command prompt in Visual Studio Code to run it and I get this error when it comes up in Google Chrome but, if I copy the url 'http://127.0.0.1:8082/' to the clipboard and shut down the initial Chrome browser, open a brand new instance from my desktop and then paste in the url it works fine!
Something about that "fresh" session uses my settings (allow any site to track my location) properly as I intended but the other way of launching through VSC doesn't ... still investigating...
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