While I was researching in order to answer a question on Stack Oveflow en español, I decided to try the code on https://developer.mozilla.org/docs/Web/API/Geolocation/getCurrentPosition1.
But I got the following error
Warning: ERROR(1): User denied Geolocation
I think that Google Chrome is considering the stack snippet as insecure. See Geolocation API Removed from Unsecured Origins in Chrome 50. Is there something that as end-user I could do to make this work?
1 The referred link was the original source of the referenced code. If you need the English version see https://developer.mozilla.org/en/docs/Web/API/Geolocation/getCurrentPosition but bear in mind that the Mozilla Developer Network docs are edited by the community and some language versions are not direct translations of another.
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
function success(pos) {
var crd = pos.coords;
console.log('Your current position is:');
console.log('Latitude : ' + crd.latitude);
console.log('Longitude: ' + crd.longitude);
console.log('More or less ' + crd.accuracy + ' meters.');
};
function error(err) {
console.warn('ERROR(' + err.code + '): ' + err.message);
};
navigator.geolocation.getCurrentPosition(success, error, options);
Related posts
- Stack Overflow en Español