The OwnTracks Drupal module provides an HTTP endpoint for the OwnTracks smartphone app.
The OwnTracks smartphone app periodically collects location data from smartphones and sends this data to an HTTP or MQTT endpoint.
The OwnTracks Drupal module leverages the following technology:
-
the Drupal entity API to store and display the data
-
the Drupal Views module to list the data
-
the Leaflet JavaScript library and a configurable map tile provider such as OpenStreetMap to visualize the data
There are some Screenshots at the end of this document.
No special requirements.
Download the module from the OwnTracks Drupal module page or fetch it with Drush or Composer:
-
drush dl owntracks
-
composer require drupal/owntracks:^1.0
There are no external dependencies. Go to admin/modules
and enable it or use
Drush:
drush en owntracks
The app can be downloaded and installed from the Android and iOS app stores:
Go to admin/config/owntracks/map
to configure the map settings. You need to
provide three settings, for example:
-
Tile layer URL
http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
-
Tile layer attribution
Map data © <a href="//openstreetmap.org">OpenStreetMap</a> contributors
-
Polyline color (hex or written-out)
blue
More info: https://switch2osm.org/using-tiles/getting-started-with-leaflet/
Go to admin/people/permissions
to configure the OwnTracks permissions. With
the create owntracks entites
, users can post location data to the endpoint and
with the view own owntracks entities
, they can view their location data (maps
and listings).
Configure the following settings:
-
Preferences > Connection > Mode
Private HTTP
-
Preferences > Connection > Host
[url of your drupal site]/owntracks/endpoint
-
Preferences > Connection > Identification
username and password of your Drupal account
- TBD
In the top right corner, tap the Upload
button (second from the right), tap
the Menu
button in the top left corner and then in the menu tap Status
. The
endpoint state message should be Response 200, 1
.
- TBD
Go to admin/content
. You should see three tabs: OwnTracks Location
,
OwnTracks Transition
and OwnTracks Waypoint
. If you don't see them right
after enabling the module, clear your caches. Click OwnTracks Location
and you
should see the location that you just uploaded from your smartphone app. In the
Operations column, click View
and you should see a map with a location marker.
Currently, the OwnTracks Drupal module supports three different OwnTracks payload types:
-
Locations
-
Waypoints
-
Transitions
Locations are the heart of the OwnTracks app. Location records are created based on motion and time, that is, the smartphone app automatically posts a location record if either a configured amount of time has passed or a configured distance was covered since the previous record.
The respective intervals can be configured in the smartphone app and it is recommended to try out different settings to get the desired location record frequency.
The OwnTracks Drupal module stores the records and displays them as:
-
Single location record with a map and additonal data such as accuracy
owntracks_location/[entity_id]
-
Track map per user
user/[uid]/owntracks
-
Most recently recorded (current) location per user
user/[uid]/owntracks/current
-
Tabular location listing
user/[uid]/owntracks/location
A waypoint is a location with a radius (aka geo-fence). Waypoints must be created in the smartphone app and uploaded manually to the endpoint. Once a user enters or leaves a waypoint's radius, the smartphone app emits a transition event (see below).
In order to create waypoints in the Android smartphone app, tap the Menu
icon
in the top left corner. In the menu tap Regions
and then in the top right
corner tap the Plus
icon (second from the right). Once the regions are added,
they have to be uploaded to the endpoint server. Tap the Options
icon in the
top right corner and then tap Publish Waypoints
.
- TBD
Go to user/[uid]/owntracks/waypoint
to
make sure that the waypoints were uploaded.
When a user enters or leaves the radius of a waypoint, the smartphone app automatically emits a transition event to the endpoint server. This event is recorded by the OwnTracks module along with additional data such as:
-
type of transition event (enter or leave)
-
timestamp when the transition occurred
-
the geolocation of the transition
-
accuracy of the geolocation
-
reference to the transition's waypoint
-
tracker that recorded the event
Go to user/[uid]/owntracks/transition
to see a listing of transitions.
This feature will be added in a future version of the module and allows for sharing waypoints and following the location of other users.