Geofence Flow Demo

by Fran T

Version 5 (February 6, 2025)

Download (250 downloads)

Demonstrates the use of the Location At? block to set up a geofence, having the Location Pick? block default to the current location, saving the chosen location for future use, formatting the location with the new coordFormat() function, and using a hidden feature to "linkify" a dialog so that a displayed address can (usually) be tapped on to show the location on a map.

The flow also demonstrates using the distance() function to work around an Android bug when determining whether you're currently at a particular location. This method is also much faster than the Location At block.

To use, tap on the location you'd like to geofence when Google Maps comes up. You can also experiment with setting the location radius (in meters), which is adjusted with the slider on the lower left side of the map.

Note: Due to a problem with the Android geofencing service, an error is sometimes thrown and the flow stops. (This happens much less frequently with the distance() workaround used here.) The problem can be alleviated by rebooting the device.

Updates:
• Now saves and restores previous settings, added Show Settings flow, improved logging
• Replaced the Location At block with a Get Location/distance() workaround, added default initial location, linkified the Show Settings dialog, improved location coordinates display with coordFormat()
• Added Clear Settings flow