Note that each time your app requests user location, your Google plan may be charged.
Sorting Lists Based on Location
1.) You can sort lists based on the distance or proximity of two locations or a static number. To do this, click on the list you want to sort and make sure the connected collection has a location property. Here we have a list of Trips:
2.) Next, click the Sorting dropdown and select the Location option that best describes the order that you want to sort in. Our our case, we want to show Trips that are closest to the user, so we'll choose Closest to Farthest.
3.) Now we need to select the location we want to compare the list items to, which in this case is the user's device location. In the Sort in relation to dropdown we're going to choose Current Device Location. It will also ask us to search for and input a Fallback Address. The fallback address will be used if the referenced sorting location cannot be found. In our case, the fallback address would be used if the user's device location could not be determined.
NOTE: If the fallback address is left empty and the user's device location cannot be determined or they did not give permission, the list filtering will be ignored.
4.) You can also choose information from the Logged in User's record or search for and use a Custom Location as well. Just note that the Custom Location will always stay the same.
Filtering Lists Based on Location
1.) We can also filter lists based on location(s) as well. In the case of our list of Trips, I may only want to show Trips that are in the same City as the user. To do this we will select the list, then click on + Add Custom Filter.
2.) In the Magic Text options we'll choose Location > City.
3.) We'll leave the operator set to Is equal to and set the second dropdown to the Current Device Locations's > City.
4.) Alternatively, we can also use the location property directly instead of using the location's sub-properties. Let's say we wanted to only show Trips within a certain distance of the user's location. We can do that too. Let's add another custom filter by clicking the +Add Custom Filter button again.
5.) This time, in the filter dropdown, click the Location option with the icon next to it.
6.) We have some new options here. In the second dropdown we can select either Is within or Is not within. Let's choose Is within.
7.) Now let's set the radius distance and the unit of measurement we want to use for comparison. We're going to choose 30 Miles, but you can also use Magic Text here as well if you wish.
8.) Lastly, let's choose the second location we're comparing the first one with, which in the case of our Trips scenario is the user's device location. Let's choose Current Device Location from the dropdown.
9.) Now our list of Trips is filtered so that it will only show Trips that are in the same city as the user, or are within 30 miles of the user.
Using Locations in Conditional Actions and Visibility
We can also apply these same filtering options to conditional visibility and conditional actions. We have the exact same set of options available in both cases, except that we can only apply one filter at a time. For example, we have some conditional visibility below that will only show the label if the user is within 1 mile of the current trip's location:
In the final example below, the button action only occurs if the current trip's city is equal to the user's device location's city.
You can also apply location filtering logic to Counts as well.
Filtering and sorting can be used on custom lists as well as all of the preset list types.