Skip to content

client geoloc

Frank van Viegen edited this page Sep 9, 2015 · 1 revision

Geoloc API

With the Geoloc API you can request locations from the current user and other users in the group. Before you can track the location of the user you need to ask permission for it, which will prompt the user with a modal.

Functions

auth(callback)

Ask for a single time location permission. This will show a modal to the user, triggering this immediately when opening the Group App is not recommended. The callback function will be called when the user has confirmed/dismissed the modal, inside this function Geoloc.track() can be used to get the location.

subscribe(callback)

Ask for location permission from the user. This will prompt the user with a modal for confirmation, the user can also share his location for only a certain time. The callback function will be called when the user has confirmed/dismissed the modal.

isSubscribed(userId)

Check if the user has shared his location, returns true if the user has shared his location forever, returns a timestamp (unix timestamp, seconds) if the user has shared his location temporarily (timestamp indicates the end time), returns false if the user has not shared his location.

track(maxAccuracy, maxAge)

Track the location of the user (if permission has been given). Returns an observable with latlong (string with lat and long concatenated seperated by ,, like 52.3,7.2), time (unix timestamp in seconds, indicating the time the location was determined) and accuracy (meters). If a new location is known from the user the state is updated (and trigger your code if you used .get()). Give maxAccuracy (meters) to indicate the detail level required, for values below 1000 it will try to use the GPS of the device. maxAge (seconds) will try to ensure the location is not older as the given maxAge.

trackAll()

Track the location of all users in the Happening. Returns an object with all known locations of users from this Happening. While one or more users have a page open where this function is active then locations of all users will be updated periodically (every ~10 minutes). Get the location data of a user with .get(<userId>) on the return value of trackAll(). The resulting location data is the same as for track().

distance(latlong1, latlong2)

Determine the distance in meters for two locations (latlong strings as described by track()).

Basic topics

API reference

  • API Reference
    • Client
      • [client plugin](client plugin)
      • [client dom](client dom)
      • [client obs](client obs)
      • [client db](client db)
      • [client server](client server)
      • [client page](client page)
      • [client ui](client ui)
      • [client form](client form)
      • [client icon](client icon)
      • [client modal](client modal)
      • [client photo](client photo)
      • [client photoview](client photoview)
      • [client time](client time)
      • [client share](client share)
      • [client map](client map)
      • [client geoloc](client geoloc)
    • Server
      • [server event](server event)
      • [server plugin](server plugin)
      • [server http](server http)
      • [server db](server db)
      • [server photo](server photo)
      • [server time](server time)
  • Example UI elements

Advanced topics

Clone this wiki locally