Location Error: alert messages

783
2
05-31-2017 08:24 AM
JohnDenis
New Contributor

I found this set of errors in several sample codes like Geolocation with a temporal renderer and Compass:

function locationError(error){
  switch (error.code) {
    case error.PERMISSION_DENIED:
      alert("Location not provided");
      break;
    case error.POSITION_UNAVAILABLE:
      alert("Current location not available");
      break;
    case error.TIMEOUT:
      alert("Timeout");
      break;
    default:
      alert("unknown error");
      break;
  }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

A end user might not know what the problem is because the alert message is not very clear. 

Except from "unknown error" which is pretty clear.... what does each specific error mean?

What might be the reason you see it on your device?

Thank you!

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

You can see those errors here: PositionError - Web APIs | MDN 

JohnDenis
New Contributor

Hi Ken,

A follow up on these properties to make sure my understanding is correct.

PERMISSION_DENIED: "The acquisition of the geolocation information failed because the page didn't have the permission to do it."

Does it mean that there is an issue with the device settings, for example Location Services is not enabled?

POSITION_UNAVAILABLE: "The acquisition of the geolocation failed because at least one internal source of position returned an internal error."

What is a internal source of position? Does it refer to having no GPS signal?

TIMEOUT: "The time allowed to acquire the geolocation, defined by PositionOptions.timeout information was reached before the information was obtained."

Does it mean that the device exceeded the lenght of time allowed in order to return the location?

Thank you!

0 Kudos