Support Topics Documentation Slack YouTube Blog

How to fetch nearby Stores using the geolocation radius?

(Marcio Prudencio) #1

Greetings to all, what’s the best way to fetch store table of users using the latitude and longitude to show all stores within a radius since the store has only relation with the user ‘objectId’ not with Geolocation. (I believe would be a Relations Depth: 2)

  1. Table Users a column location (with relation 1:1 to Geopoint).
  2. Table Store has a relation 1:1 to table Users (objectId).

The goal is to fetch the store and users data based in geopoints.

I already tried some variations from the examples on (geo_radius_based_search.html) but couldn’t reach the store table data just the user.

Looking for Rest API or Javascript Backendless examples. Regards

(Anton Govorushkin) #2


You’ll need to execute search against your Store table. Lets say you have:

  1. a relation from Store to Users table called userData
  2. a relation from Users to geo points called location

You need to search with a where clause like: userData.location is not null. This query will result in an array of STORES which are related to Users that have any location. If you add relation depth = 1 you will receive User objects as well. Relation depth = 2 you will also get location objects.

To adapt the query to your needs follow these docs: - REST - JS