Help with search results radius

I am working on a page where I can type in an address and you can select from the geographical addresses in the dropdown. When a button is clicked the user is navigated to the next page depending if there is an agent available within 5 KM radius. How can I do this? I’m struggling to set this up…

I created a geographic searchbox for allowing users to enter their location to check if there is at least an agent within a 5 km radius from his adress. If yes, the user will be redirected to the next step (another page). If no, the user will be redirected to a sorry page.

There is probably more than one way to achieve this but here is how I would do it:

Have a data type “Agent” with a field of type geographical address and one field to determine the availability (preferably of type boolean). Send a parameter to a page where you want to display the agents with the address from the input.

On that page, you do a search for Agents and constrain the search to the address from the url and the availability:

00 29

If the search result is 0, show a “sorry” group and from there you can do whatever you want.

I solved the issue by the following.

only when - do a search for - agents - add a new constraint - address is within x miles/km of searchbox’s value - count is > 0

and

only when - do a search for - agents - add a new constraint - address is within x miles/km of searchbox’s value - count is < 1