Segment SDK

Geolocation

Constructor
new Geolocation()

GeoLocation constructor. This class handles determining a users current location

Summary

Methods
getCurrentPosition Returns geo-location of the current position.
Type definitions
onsuccess The callback function to be invoked when geo-location was successfully retrieved.
onerror The callback function to be invoked when get geo-location could not be retrieved successfully.

Methods

getCurrentPosition(callbackObject)

Returns geo-location of the current position.

Parameters
Name Type Description
callbackObject Object The callback object

Properties
Name Type Description
onsuccess da.Geolocation~onsuccess The callback function to be invoked when the geo-location of the current position was successfully retrieved.
onerror da.Geolocation~onerror TThe callback function to be invoked when the geo-location of the current position could not be retrieved successfully.

Type definitions

onsuccess(coordinates)

Type
function

The callback function to be invoked when geo-location was successfully retrieved.

Parameters
Name Type Description
coordinates Object

Properties
Name Type Description
latitude number Latitude
longitude number Longitude
accuracy number The accuracy used for horizontal positioning error. The smaller the value is, the higher the accuracy is.

onerror(error)

Type
function

The callback function to be invoked when get geo-location could not be retrieved successfully.

Parameters
Name Type Description
error Object

Properties
Name Type Description
code number Error code
  • 900: failed to get GPS value.
  • 999: unidentified error
message string The error message