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

4107
6
02-23-2021 05:03 PM
GlenShepherd
Esri Contributor
5 6 4,107

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
LindsayRaabe_FPCWA
Occasional Contributor III

In the past, I've seen presentations from ESRI and partners (think one was Auckland City Council in New Zealand) that showed the live(?) location of mobile contractors undertaking public works (not public - in house only). I believe this was part of a WorkForce demo. I assume these functions are enabled by the Tracker feature in Field Maps? 

Can ESRI products consume live location data feeds from external applications as well (i.e. a fleet of emergency vehicles)?

GlenShepherd
Esri Contributor

Hi @LindsayRaabe_FPCWA ,

Certainly an interesting point. The "worker" feature layer created from an ArcGIS Workforce project is indeed tracking enabled, whereby the location of a feature (worker) is refreshed every 'x' minutes when the mobile app is in use. And these layers can actually be shared publicly by the data owner. Whereas if we create layers using the ArcGIS Tracker app in ArcGIS Online, these layers can not be shared publicly.

So there might also be a workflow there for re-purposing Workforce feature layers as tracking-enabled public layers.

However, if we're looking to configure web apps/maps with real-time live data feeds (such as fleet tracking), a more robust platform such as ArcGIS Enterprise with a GeoEvent Server site or even utilising the ArcGIS Velocity add-on for ArcGIS Online might be necessary.

GarethBaker1
Occasional Contributor III

Hi Glen,

Was looking for confirmation about the location tracking layers not being able to be shared to the public from AGOL and came across your post. This is an interesting approach to make use of QuickCapture instead of FieldMaps and something that I will take a look at.

You mention that applying this method to multiple users could be problematic but do you think it could be robust enough to support a few separate users? Our use case is to start tracking our small fleet (three at most) of company buses which run staff between the office and train station and have the info appear on a publicly available map. Feels like the options of GeoEvent or Velocity would be overkill for this scenario.

Thanks
Gareth

GlenShepherd
Esri Contributor

Hi @GarethBaker1 ,

I'd certainly recommend setting up a trial project where you can monitor how the feature class updates and web application respond to multiple users streaming new features. If you had a completely separate feature class for each user, it would probably perform better than multiple users streaming updates/edits to a single feature class.

But how well this approach works will all depend on a variety of factors:

  • streaming intervals
  • refresh intervals
  • network connections
  • number of users
  • submitting to one feature class or individual feature classes

etc...

I'd roll out a test environment first and consider whether the behaviour suits your organisation's needs.

WilliamRockwell1
New Contributor III

This is great, but I'm concerned quick capture is going to be eclipsed by Field Maps, correct?

Can I replicate this workflow using Field Maps if need be?

GlenShepherd
Esri Contributor

Hi @WilliamRockwell1 ,

Incorrect! But I understand your concern haha.
ArcGIS QuickCapture and Survey123 will actually remain independent of the ArcGIS Field Maps amalgamation. So they won't be going anywhere.

But you can also use ArcGIS Field Maps if you wish. The following documentation covers streaming featrues usign ArcGIS Field Maps: https://doc.arcgis.com/en/field-maps/android/help/capture.htm#ESRI_SECTION1_0886C23DBF944A9FAC5735E5...

 

About the Author
Esri Australia Client Success team member