> For the complete documentation index, see [llms.txt](https://help.adalo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.adalo.com/database/location/comparing-locations.md).

# Comparing Locations

*Skill Level: Expert*

***

## Before You Begin

* Ensure you have generated your [Google API Key](/database/location/getting-your-google-api-key.md)
* Know about the [location property type](/database/location/the-location-property-type.md) and [location magic text](/database/location/location-magic-text-and-formatting.md)
* Know how to get the [user's device location](/database/location/getting-the-users-location.md)
* You will need a paid Adalo plan to use this feature.
* Know about [conditionals and filtering](/component-basics/conditions-and-filtering.md)
* Note that each time your app requests user location, your Google plan may be charged.

{% hint style="warning" %}
Using browser languages other than English may break filtering rules.&#x20;
{% endhint %}

***

## &#x20;Walkthrough

### 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:

   ![](/files/egJDI061VojxTjTxugx3)

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**.

   ![](/files/A3WR9mtqQWLOQTlpr4WC)

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.

   ![](/files/3Fb6ItdCxoEvML5jG6vv)

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.

   ![](/files/tPPpzCz4yrK4koQUz82D)

{% hint style="info" %}
**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.
{% endhint %}

### 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.**

   ![](/files/QHvfDwYCYP2YwJ7WSomT)

2. In the Magic Text options we'll choose **Location > City.**

   ![](/files/E4IFTQyrzvnRBG4rCL20)

3. We'll leave the operator set to **Is equal to** and set the second dropdown to the **Current Device Locations's > City.**

   ![](/files/lrjB0XTVHcqID94Xk3ke)

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.

   ![](/files/LLr7iiomCyI2hodueG21)

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.**

   ![](/files/SXEPSP3jPRVYLExv7OAt)

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.

   ![](/files/ruImdkiFtCZ8yycdQ5e3)

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.

   ![](/files/QrIGW14O4UdM9sZ2qJ1d)

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.<br>

{% hint style="warning" %}
**Heads up: location filters are "heavy."**

Each location filter (like **Is within** a radius) carries a lot of detail behind the scenes (the place name, coordinates, and full address). When you combine several filters using **OR** conditions, that location detail is repeated in every condition, and a filter can get large enough that the list stops loading and shows up empty in the previewer with no clear error.

If a list with location filters won't load, try this:

* Reduce the number of **OR** conditions on the list (each one re-adds the full location filter).
* Use the location filter in as few conditions as possible, or split a very complex list into separate, simpler lists.
  {% endhint %}

### Using Locations in Conditional Actions and Visibility

1. 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:

   ![](/files/n27YFCI1DII2gh5skO5M)
2. 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.

![](/files/zUoZiv0x2vE8qgJAvEGz)

***

## Learn More

* You can also apply location filtering logic to Counts as well.&#x20;
* Filtering and sorting can be used on custom lists as well as all of the preset list types.
* Check out our [course in the App Academy](https://appacademy.adalo.com/course/geolocation-uber-airbnb) about using Location.

***

## Help

If you need additional help with this article, you can always ask in our [community forum](https://forum.adalo.com/)! Be sure to paste the link to this article in your post as well!


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.adalo.com/database/location/comparing-locations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
