# How to Connect Two User's based on distance

**URL:** <https://forum.bubble.io/t/how-to-connect-two-users-based-on-distance/289359>\
**Category:** Need help\
**Created:** [October 21, 2023, 1:10am UTC](https://forum.bubble.io/t/how-to-connect-two-users-based-on-distance/289359 "2023-10-21T01:10:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![irodgers](https://avatars.discourse-cdn.com/v4/letter/i/e36b37/32.png) [@irodgers](https://forum.bubble.io/u/irodgers)\
**Post date:** [October 21, 2023, 1:10am UTC](https://forum.bubble.io/t/how-to-connect-two-users-based-on-distance/289359/1 "2023-10-21T01:10:13Z")

</div>

Hello! I am developing a sort of “Uber Clone”. I am differentiating drivers and customers based on an “Approved Driver” data field of “Yes/No” under the User data type. By default it is “no” and since I know all of my drivers I am planning on manually changing their “Approved Driver” status to “Yes” on the backend. When a customer presses the “Confirm” button on their request page, I am having trouble with 2 things. 1) Searching for Users based on their “Approved Driver” status being “Yes” and 2) Connecting them with this nearest Driver. I have the Google Maps Extended API set up and functioning properly.

---

<div class="post-metadata">

**Author:** ![tylerboodman](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tylerboodman/32/242142_2.png) [@tylerboodman](https://forum.bubble.io/u/tylerboodman)\
**Post date:** [October 21, 2023, 1:42am UTC](https://forum.bubble.io/t/how-to-connect-two-users-based-on-distance/289359/2 "2023-10-21T01:42:27Z")

</div>

If you have your Google Maps API key set in your app settings, you can `Search for Drivers`, constraint `[geographical address field] is within [distance] [unit] of Current user's [geographical address field]`

Then whatever determines a driver being a approved driver, include that as a constraint as well

---

<div class="post-metadata">

**Author:** ![tylerboodman](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tylerboodman/32/242142_2.png) [@tylerboodman](https://forum.bubble.io/u/tylerboodman)\
**Post date:** [October 21, 2023, 1:46am UTC](https://forum.bubble.io/t/how-to-connect-two-users-based-on-distance/289359/3 "2023-10-21T01:46:11Z")

</div>

This would be like a dummy-radius check, not actually routing using real street distance, you could make the radius bigger, then do a Route API or Distance Matrix API request and pick closest drivers that way 🙂

---

<div class="post-metadata">

**Author:** ![irodgers](https://avatars.discourse-cdn.com/v4/letter/i/e36b37/32.png) [@irodgers](https://forum.bubble.io/u/irodgers)\
**Post date:** [October 21, 2023, 1:49am UTC](https://forum.bubble.io/t/how-to-connect-two-users-based-on-distance/289359/4 "2023-10-21T01:49:40Z")

</div>

Where exactly would I add this? I have been trying to do this in the workflow of the User’s “Confirm” button by Creating a New “Trip” (data field) and updating the Driver = Search for User’s Current Location within 50 miles Current User’s Current Location. But I get an error message saying that the “Value should be a User but right now it is a List of Users”

---

<div class="post-metadata">

**Author:** ![tylerboodman](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tylerboodman/32/242142_2.png) [@tylerboodman](https://forum.bubble.io/u/tylerboodman)\
**Post date:** [October 21, 2023, 1:57am UTC](https://forum.bubble.io/t/how-to-connect-two-users-based-on-distance/289359/5 "2023-10-21T01:57:38Z")

</div>

The search gives you a list, so you need to sort by distance and pick the closet one:

 ![Screenshot_10](https://us1.discourse-cdn.com/bubble/original/3X/f/7/f7c8261c48ef0a1c1339c7870ebe1cc6f0300759.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [December 30, 2023, 1:11am UTC](https://forum.bubble.io/t/how-to-connect-two-users-based-on-distance/289359/6 "2023-12-30T01:11:02Z")

</div>

Closed on December 30, 2023, 1:11am UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
