---
title: "Showing distance and sorting by distance in radius search results"
date: 2026-10-07
updated: 2026-10-07
author: "Block MCP (service account)"
link: "https://www.gravitykit.com/docs/gravityview-pro/maps-premium-view/radius-search-distance-and-sorting/"
category: "GravityView Pro > Maps Layout"
---

With the [GravityView Maps Layout](https://www.gravitykit.com/products/maps/), a View with a radius search can show how far each entry is from the searched location and list the nearest entries first.

## Before you start

- You need Maps 3.9.0 or newer and GravityView 2.57 or newer. With older versions, the **Distance** field and the distance sorting setting do not appear.
- Your View needs a working radius search. If you have not set one up, follow [How to enable radius search](https://www.gravitykit.com/docs/gravityview-pro/maps-premium-view/how-to-enable-radius-search/) first.

## How distance is measured

Distance is measured in a straight line between the searched location and the entry’s map position (“as the crow flies”). A route by road is usually longer than the distance shown.

The unit follows the search. A search in miles shows distances in miles (`mi`), and a search in kilometers shows them in kilometers (`km`).

## Step 1: Show the distance for each entry

- Edit your View and open the **Multiple Entries Layout** tab.
- In the area where the distance should appear, click **Add Field** (in a Table View, **Add Table Column**) and choose **Distance**.

![The field picker in the Multiple Entries layout filtered to the Distance field](https://www.gravitykit.com/wp-content/uploads/2026/09/maps-radius-distance-01-add-distance-field.png)
- Click the gear icon on the new field to open its settings. Set **Decimal places** to the number of digits to show after the decimal point, from 0 to 5. The default is 1.
![The Distance field settings with the Decimal places setting](https://www.gravitykit.com/wp-content/uploads/2026/09/maps-radius-distance-02-distance-decimal-places.png)
4. Click **Update**
On the front end, each entry in a radius search now shows a value such as `2.4 mi` or `12.0 km`.

**Note**: The **Distance** field shows a value only during a radius search, and only the Multiple Entries layout offers it.

## Step 2: Sort results by distance

1. Edit your View, scroll to the **Settings** box, and open its **Maps** tab.
2. Under **Radius Search Settings**, find **Radius Distance Sorting** and check **Sort radius search results by distance**.

![The Radius Distance Sorting setting on the Maps tab of the Settings box, with Sort radius search results by distance checked](https://www.gravitykit.com/wp-content/uploads/2026/09/maps-radius-distance-03-radius-distance-sorting.png)
- Click **Update**.
During a radius search, the nearest entries now come first, and the order continues across all pages of results. The View’s own sort order applies only to entries whose distances are exactly equal. Distances are compared before rounding, so two entries that both show `2.4 mi` still appear nearest first. Without a radius search, the View keeps its normal sort order.

## Common questions

### The Distance field or the sorting setting is missing

Both features need GravityView 2.57 or newer and Maps 3.9.0 or newer. With both plugins updated, look for the field in the **Multiple Entries Layout** tab, because the Single Entry layout does not offer it.

### Changing how the distance looks

The `gk/gravitymaps/fields/distance/output` filter changes the text the field shows. This example adds the word “away” after every Distance field value on your site:

```
/**
 * Adds the word "away" after the Distance field value.
 *
 * @param string $output   The distance and its unit, for example "2.4 mi".
 * @param float  $distance The distance in the unit of the search.
 * @param string $unit     The unit of the search: "mi" or "km".
 *
 * @return string The text the Distance field shows.
 */
add_filter( 'gk/gravitymaps/fields/distance/output', function ( $output, $distance, $unit ) {
    return $output . ' away';
}, 10, 3 );
```

Read here how to add these code samples to your website: [Where to put code samples.](https://www.gravitykit.com/docs/gravityview/customizing-your-views/where-to-put-code-samples/)

The filter’s parameters are listed on its [developer documentation page](https://www.gravitykit.dev/docs/gravityview-maps/filters/gk-gravitymaps-fields-distance-output/).

## Related

- [How to enable radius search](https://www.gravitykit.com/docs/gravityview-pro/maps-premium-view/how-to-enable-radius-search/)
- [Radius Search: Request Location](https://www.gravitykit.com/docs/gravityview-pro/maps-premium-view/radius-seach-request-location/)