Query Database by distance from location

Hello Community,

I’m attempting to implement what I feel like is a pretty straightforward feature of allowing the user to find all services within a specific distance (i.e. within 20 miles) of their input location.

My services database has a location field but I’m struggling to find the best way to implement the query logic. The Wix query parameters do not seem to support this use case?

Any insights would be appreciated.

“Straightforward”? Not quite. You will need to calculate the distance between the input location and each location in your database. To do this, you will need to avail yourself of a distance calculating service such as Google Maps . See the example Google Place example to see how to get started using the API. An Internet search might turn up some other distance calculating services.

Adam, did you ever find a solution?

When I needed to calculate the distance between 2 given latLng coordinates, I installed the geolib NPM, and I think it worked well. It is very easy to use.

J.D. Thanks so much for the quick response!! I will take a look.