6th Dec '25
/
0 comments

Location-based Distance Filtering on a Google Map in Bricks

Updated on 7 Dec 2025

This Pro tutorial provides detailed instructions to set up Bricks' Map element with additional location-based distance filtering or proximity search input.

We shall create a custom shortcode for showing the location input field and distance dropdown.

[posts_map_filter unit="km" default="50" options="1,3,5,10,25,50,100,250"]

unit can be km or mi.

Clicking the crosshair/target icon asks user for their permission to use their location and when granted, fills their address in the input field.

Below that is the standard Bricks search filter so visitors can quickly filter the posts by their titles or content.

The list of posts (of Location CPT, can be of any post type) will be shown using a Bricks' Posts query loop in a fixed-height column with a gradient overlay indicating the visitor that there are more underneath.

[optional] Hovering on the post title will show 'View details on the map' tooltip. This is done using BricksExtras' Popovers / Tooltips.

Clicking a post title will open the info window for that post on the map.

The address for each location post is set using ACF's Google Map field.

We have full control on what appears inside the info window when the red marker is clicked anytime or when a post is clicked and the info window opens on the map to show that post's address. This is set in a Bricks template of the type Popup.

In this tutorial, we shall show the post title, values of phone number and opening hours custom fields and a read more button that links to the post's permalink.

Input fields can be reset at any time by clicking the Reset button. We shall also trigger it when text inside the proximity input is cleared.

Step 1

Get your Google Maps API key if you don't already have one. Doc

Paste your Google Maps: API key at Bricks → Settings → API keys and save settings.

Step 2

Create your CPT (optional, the standard posts can also be used) and the corresponding ACF field group.

Step 3

Create some posts of your post type and populate the ACF fields, especially the address.

Step 4

Create a Bricks template of the type Popup named say "Map info box".

JSON of the Container (select all the text, copy and paste in Bricks editor)

Step 5

If the Bricks child theme is not active, upload it and make it active. This can be done even if the site is live.

Create a directory named assets in your child theme directory.

Create a directory named js in the above directory.

Create a filed named posts-map-filter.js in the above directory having the following code:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 612 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

ACF Checkbox Items with Custom SVG Bullets in Bricks

ACF Checkbox Items with Custom SVG Bullets in Bricks

We walk through outputting list items with SVG icons based on the choice of a ACF Checkbox field.
Categories:
Tags:
Pro
Filtering Query Loop Posts by a Non-empty Custom Field in Bricks

Filtering Query Loop Posts by a Non-empty Custom Field in Bricks

This Pro tutorial shows how we can prefilter the results of a query output by a Bricks query loop to only those for which the…
Categories:
Tags:
Pro
Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

How to register a new dynamic tag for setting excerpt word limits and outputting an ellipsis (...) at the end.
Categories:
How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 1)

How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 1)

This tutorial provides the PHP & JS codes that can be pasted in order to create a dynamic map with markers populated from a custom…
Categories: