kafe.geolocation

Class

Version 1.1.0

Methods to access geolocalization information about the client.

Source: dist/geolocation.js

Methods

locate

Get the current geolocalization information of the client.

locate
  • parameters

Parameters:

  • parameters Object

    Parameters for the current request.

    • [selector] String|jQueryObject|DOMElement Optional

      Element used to show status messages.

    • [lang = CURRENT_ENV_LANG] String Optional

      A two character language code.

    • [success] Function Optional

      Callback triggered when geolocalization informations have been successful retrieved. An object containing the informations is passed as the first argument.

    • [error] Function Optional

      Callback triggered on geolocalization errors. The error message is passed as the first argument.

    • [options] Object Optional

      Options given to optimize getCurrentPosition.

Example:

kafe.geolocation.locate({
					    selector: '#GeoLocStatus', lang: 'en',
					    success: function(coords) {
					        console.log('latitude: ' + coords.latitude);
					        console.log('longitude: ' + coords.longitude);
					    }
					    error: function(msg) {
					        console.log('Cannot geoloc: ' + msg);
					    },
					    options: {
					        enableHighAccuracy: false,
					        timeout: 5000,
					        maximumAge: 0
					    }
					});
$('#GeoLocStatus').kafe('geolocation.locate', {});