Webshims Lib

Polyfill only the incapable browsers

Demo/About/Documentation geolocation API

The geolocation-feature implements the navigator.geolocation API. The following methods are available:

  • navigator.getCurrentPosition: successCallback, errorCallback and options ({timeout: number}) are supported
  • navigator.watchPosition: in shim identical to getCurrentPosition, except it returns an useless ID
  • navigator.clearWatch: is noop in shim

The shim uses the geolocation information provided by http://freegeoip.net and/or googles API-Loader

Options for geolocation

  • confirmText (string): confirm text for requesting access to geo data.
$.webshims.setOptions('geolocation', { confirmText: '{location} wants to know your position. It is Ok to press Ok.' }); navigator.geolocation.getCurrentPosition(function(pos){ alert("Thx, you are @ latitude: "+ pos.coords.latitude +"/longitude: " + pos.coords.longitude); });