Am trying to add geo location functionality to site using google geocode as fallback, so far it works properly with chrome. When i try it out in firefox it doesn t it only shows the location prompt Heres my code
function add_location() {
if (navigator.geolocation)
{
$("#pheed-location").fadeIn();
$( .loading-indicator ).fadeIn();
navigator.geolocation.getCurrentPosition(handle_geolocation_query, handle_location_errors);
}
}
function parseLocationError(error)
{
switch(error.code)
{
case error.PERMISSION_DENIED:
errorMsg = "User did not share geolocation data";
code = 1;
break;
case error.POSITION_UNAVAILABLE:
errorMsg = "Could not detect your current position";
code = 2;
break;
case error.TIMEOUT:
errorMsg = "Retrieving position timedout";
code = 2;
break;
default:
errorMsg = "Unknown error";
code = 0;
break;
}
var _error = {"msg":errorMsg,"code":code};
return _error;
}
/**
* Handles error from geolocation
* @param error object
**/
function handle_location_errors(error) {
var msgDisplay = $( .loading-indicator );
//Error message
var errorMsg ="";
console.log(error);
//Set error message base on error code
var Error = parseLocationError(error);
if((Error.code === 1) || (Error.code === 2)) {
msgDisplay.html( ).fadeOut();
msgDisplay.html(Error.msg).fadeIn();
if(Error.code === 2)
$("#location-entry").fadeIn();
}
}
I add the "console.log(error)" to ensure the error are being returned. The errors are logged properly in chrome, but dont seem to work at all in firefox. What could be the problem?