I’ve following code to track geolocation of the user
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(
function(loc) {
alert(loc.coords.latitude + ',' + loc.coords.longitude);
},
function(error) {
switch(error.code)
{
case error.TIMEOUT:
alert('timeout');
break;
case error.POSITION_UNAVAILABLE:
alert('postion unabliable');
break;
case error.PERMISSION_DENIED:
alert('permission denied');
break;
case error.UNKNOWN_ERROR:
alert('caught unknown error');
break;
default:
alert('default block');
}
},{timeout:10000});
} else {
alert('browser not support to track location');
}
It is working fine,but I’ve some issues depending on browsers
Chrome: When user closes the popup then need to show some message to the user,for that what I’v to do?
Firfox: 1) Need same thing for firefox.
2)If user allows to share the location,then location coordinates are displaying as per code,if user refreshes the browser popup is displaying,again user allows to share the location then location coordinates are not displaying,actually location coordinates have to display as per my code.
3)Same problem is facing for if user selects ‘Never Share Location’ option
4)If user selects ‘Not Now’ option,I need to display alert message,for that what I’ve to do?
Majorly,when user closes the popup I need to do some task even though location found.
Do handle this situation,whenever
scriptloads you need to execute default functionality,even though user closes the popup,default functionality stills works,if user allows for tracking the location then based on user location that functionality will work.If you follow this approach,it will work in all cases.I hope it might be help full.