When trying to use the HTML5 geolocation api on mobile chrome for ios, my app throws a "Permission Denied" error without even prompting to share my location. Has anyone else run into this issue?
PS. This happens locally and on a heroku instance.
Here is the code I am running on document ready
var displayCloseFoo = function(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
};
var displayError = function(error) {
var errors = {
1: 'Permission denied',
2: 'Position unavailable',
3: 'Request timeout'
};
alert("Error: " + errors[error.code]);
};
var runGeo = function(){
if (navigator.geolocation) {
var timeoutVal = 10 * 1000 * 1000;
navigator.geolocation.getCurrentPosition(
displayCloseFoo,
displayError,
{ enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
);
}
else {
alert("Geolocation is not supported by this browser");
}
};
runGeo();
Thanks
Problem: GPS Status screen reports 'User denied location' in Chrome browser on Android phone/tablet. Solution: This error message means that you need to give your phone or tablet permission to access the GPS.
You have to explicitly allow Mobile Chrome to use Location Services in ios. In ios6 you can achieve this by going to Settings->Privacy->Location Services and toggling Chrome to On.
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