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 630 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Dynamic Google Map in Bricks – Markers from ACF Repeater Google Map Sub Field Values

Dynamic Google Map in Bricks – Markers from ACF Repeater Google Map Sub Field Values

This Pro tutorial provides the steps to show the addresses entered using a Google Map sub field of a ACF Repeater as markers on a…
Categories:
Pro
Bidirectional Relationship between a CPT and a Taxonomy of another CPT using ACF in Bricks

Bidirectional Relationship between a CPT and a Taxonomy of another CPT using ACF in Bricks

A couple of members asked: I have a cpt called "Markets" aand a cpt "tools". Tools have a taxonomy "tools group". How can i create…
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:
Pro
ACF Date Field Value Custom Format in Bricks

ACF Date Field Value Custom Format in Bricks

In the Bricks forum, a user asks: Hi there, I am setting up an events calendar using bricks. In some circumstances I would like to…
Categories:
Tags:
Pro
ACF Term Meta on Single Posts in Bricks

ACF Term Meta on Single Posts in Bricks

Consider this scenario: CPT: Project Custom taxonomy: Project Type Each project will be assigned only one project type. Project Type taxonomy's custom field: Project Type…
Categories:
How to populate a map with dynamic markers from a CPT using ACF in Bricks (PART 2)

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

This tutorial provides the PHP & JS codes that can be pasted in order to create a flying effect on map markers each time your…
Pro
Sorting ACF Relationship Posts by Date Meta in Bricks

Sorting ACF Relationship Posts by Date Meta in Bricks

Consider the following setup: CPT: Events ACF Fields:Event Date Information (Group)|__Event Date (Date Picker)Pick Sub Events (Relationship) An Event can have 1 or more related…