Select to view content in your preferred language

“Near Real-Time” Location Tracking for public Web Apps

5329
6
02-23-2021 05:03 PM
GlenShepherd
Esri Contributor
5 6 5,329

The Premise

While ArcGIS Tracker layers ('Tracks' & 'Last Known Location') can be used to live stream location data back to our web portal, this data is protected by additional security settings which prevent them from being shared publicly. Understandably, this is is by-design to protect personal privacy and our location being accidentally shared with the wrong people.

There is however, another method by which we can configure a near-live location stream for public tracking purposes... Consider the following public web app purposes:

  • Tracking a parade along a local street route
  • Locating a school bus on its ring-route
  • Re-tracing your own steps in the field

These are fairly simple and low storage (credit consumption) purposes for which we can use the ArcGIS Online suite to solve.

The workflow in this blog post will combine the following ArcGIS products to configure a public web app for near-live location streaming and tracking:

  • ArcGIS Online
  • ArcGIS QuickCapture (Field Apps Bundle)
  • ArcGIS Web AppBuilder
  • ArcGIS Pro (if necessary, see "Important Considerations" below)

Disclaimer:
ArcGIS QuickCapture will be best suited to streaming this magnitude features from a single device. Attempting to apply this method to multiple users (e.g. a fleet of cars) within a single project, will likely produce performance issues and a less-and-less "live" experience.

 

The Workflow

In this example, we're going to track a theoretical IceCream truck, as it makes its way throughout a neighbourhood.

In ArcGIS Online, we'll want to create a point feature layer - I've named mine "Icecream Truck".

Then, access the QuickCapture Designer via the App Shortcut menu in ArcGIS Online, or using the URL:  https://www.arcgis.com/apps/quickcapture/ 
Creating a new QuickCapture project is easy:

  1. Click "New Project"
  2. Choose "Start from existing layers" and select your point feature layer
  3. Click "Next" and "Create" your project
  4. Please see "Get started with ArcGIS QuickCapture" and "Configure a Project" for more information on the design features of ArcGIS QuickCapture projects
  5. Select the button for your point feature layer, go to the "Data" tab and ensure that "Streaming points" is selected:

    2020-12-30_13-05-12.png

  6. You may also want to go to Settings > General > and enable/disable required accuracy, as well as set a "Distance Threshold" between captured points.
  7. Then "Save" your project
  8. Now, we (or the field worker) will need to download and install the ArcGIS QuickCapture mobile app to our mobile device > log in > select the '+' symbol > Browse Projects > Download the QuickCapture project
  9. Then, go to QuickCapture Settings > Autosend > enable "On" > and select Interval = 'Immediately'

This last step will ensure that streamed point features are synced back to the feature layer in ArcGIS Online as soon as they are captured.

 

Now, back in ArcGIS Online...

  1. Go to Content, then find and Select your point feature layer
  2. Choose to "Create View Layer"
  3. Give the new view layer a Name, Summary, and Tags
  4. Then choose to "Open in Map Viewer"
  5. In your web map, open the drop-down menu for the View Layer > Set View Definition > Define Features

    ViewDef1.png

  6. We can then use the 'Fix Time' attribute (created by QuickCapture) to set an expression to only display the points that have been streamed in the last x amount of time, such as:
    Fix Time - In the last - 5 - minutes

    ViewDef2.png

  7. Furthermore, we want to set our 'Refresh Interval' on this layer, to the lowest possible (every 30 seconds) so that the web map is up to date as often as possible for our web app audience...

    RefreshInt.png

  8. Open the drop-down for the view layer again and choose "Save Layer"
  9. Save the web map and give it a Name, Tags, and Summary... 

 

Now, let's add the new web map to a Web Application...

  1. Go to Content > Create > Web AppBuilder
  2. Choose '2D' > Give the Web App a Name, Tags, and Summary > Click "Create"
  3. Choose a theme
  4. Add your web map
  5. Add widgets which may be of interest:
    1. Bookmarks (from web map)
    2. Filter (you may wish to provide the user with the ability to filter by the 'Fix Time' attribute even further.)
  6. Save the Web Application
  7. In ArcGIS Online > Content > set sharing to "Everyone (Public)" for the following content:
    1. Feature Layer View
    2. Web Map
    3. Web Application

 

Now we (or the field worker) can begin streaming their location from ArcGIS QuickCapture, and their movements can be observed to update every 30 seconds in the web application, with their location over the past 5 minutes trailing behind them!

Example:

Example Output: Points collected in QuickCapture with a 10m Distance Threshold and public Web AppBuilder app with an 'in the last 0.5 minutes' Filter widget enabled, for a car driving through a local neighbourhoodExample Output: Points collected in QuickCapture with a 10m Distance Threshold and public Web AppBuilder app with an 'in the last 0.5 minutes' Filter widget enabled, for a car driving through a local neighbourhood

 

Additional Considerations

View Layer Filters: Features will disappear from the map after our view layer's time threshold has passed. To work around this, we could apply a "most recent" filter to the feature service's JSON by following the workflow outlined here: https://community.esri.com/t5/arcgis-online-documents/display-latest-feature-in-a-feature-service/ta...

And using the following syntax as a guide, we can return the most recent 5 points per username:

 

{
	"viewLayerDefinition": {
		"topFilter": {
			"orderByFields": "OBJECTID ASC",
			"groupByFields": "Creator",
			"topCount": 5
		}
	}
}

 

 


Storage Concerns: Streaming and storing features in bulk using ArcGIS QuickCapture is going to have an increasing impact on ArcGIS Online credit consumption over time. We need to remember to batch delete the collected point features once they are no longer relevant to our purpose. This can be done easily in ArcGIS Pro by doing the following:

  1. Open ArcGIS Pro, connect to ArcGIS Online as your 'Active Portal' and sign in.
  2. Go to the 'Catalog' pane, and on the 'Portal' tab, find your streaming feature layer.
  3. Add this layer to the map, right-click it in the 'Contents' pane and open its attribute table.
  4. Ctrl + A will add all features to selection.
  5. Then click the 'Delete' button to remove them.

GlenShepherd_0-1614128202134.png

 

 

 

 

6 Comments
About the Author
Esri Australia Client Success team member