4
I’m having trouble retrieving user geolocation on the site. Localhost works, but not on the network. I’m guessing the problem is that it has no SSL certificate and the site is accessed by HTTP and not HTTPS.
See the error:
getCurrentPosition() and watchPosition() are deprecated on insecure Origins. To use this Feature, you should consider switching your application to a Secure origin, such as HTTPS. See https://goo.gl/rStTGz for more Details.
My code:
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(pos){
var lat = pos.coords.latitude;
var lng = pos.coords.longitude;
console.log(lat + ' - ' + lng);
}
}
And in Safari it doesn’t work. You can’t recover geolocation from Localhost. In other browsers it works normally on Localhost.
About safari, I saw that to support geolocation, the version has to be 5.0 +.
– Matheus
Peter Park, remember that this type of interaction with the browser requires the permission of the end user of your application. Otherwise all your efforts will be in vain
– Vinicius Dutra
Really, @Viniciusdutra ? Gee... Life...
– Diego Souza
you can always use https://letsencrypt.org/
– MoshMage