Search code examples
javascripthtmlgeolocation

Getting Geolocation KCLError Domain error


I am working on a site that uses HTML5 Geolocation. Here is code I am using:

html:

<button onclick="getLocation()">Try It</button>

js

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else {
    console.log('Geolocation is not supported by this browser.');
  }
}

function showPosition(position) {
  console.log(position.coords);
  alert(position.coords.latitude);
  alert(position.coords.longitude);
}

Everything seem to works well, but some users are getting KCLError Domain error. Here are their comments:

  • This happens regardless of browser - Safari and Chrome both affected(tablet);
  • Presumably the error occurred internally and isn't displayed on the screen;
  • When a user presses 'button' it shows the error and fails.

Error itself

I did not found any solution or reasons related to HTML about this error.


Solution

  • Everything seem to works fine, but some users get KCLError Domain error

    I'm guessing it might be a device related bug than of an app. From my point of view your code is pretty much "standard" when it comes to consuming the API.

    • Ask one of users,that can catch this error, to testing the same feature on this site
    • Try checking their wi-fi settings or whether or not they have their wi-fi turned on. For more details, checkout this OS.

    Update from OP:

    • So the KCLError Domain error error was not retated to html5 geolocation code but to users GSM triangulation, reverse IP geolocation or WiFi network database lookups.

    • I was confused by this error because it was not self explanatory and here is where I made a mistake, this error is not strict error code it just additional error message and the error code was error.POSITION_UNAVAILABLE and this code is well known.

    UPDATE FROM CUSTOMER:

    I upgraded the OS on my iPad today and location services have started working again. So all good now