In my Users table I created a field [current_location] of type GeoPoint that I use for saving their current location of the user at time (s)he logins in the app.
I would like to search within radius (let’s say 10 Miles) of these Geopoint records in Users table and return the usernames of all Users within the area.
Find objects within certain distance from a geo point
With the ability to link data objects with geo points, you can search for data objects by distance. This type of search returns all data objects which satisfy the whereClause condition and located within the specified distance. Distance-based search uses a special function in whereClause of the search request. The syntax of the function is:
distance( center point latitude, center point longitude, columnname which contains geo point.latitude, columnname which contains geo point.longitude )<operator> units-function(value)
where:
<operator>- Possible values are <, >, =, >=, <=units-function- Defines the units of measure for the distance. Possible values are:ft( X ) - the distance value X is expressed in feet km( X ) - the distance value X is expressed in kilometersmi( X ) - the distance value X is expressed in milesyd( X ) - the distance value X is expressed in yardsFor example, the following whereClause expression searches for data objects located within 200 miles from the point at 30.26715, -97.74306. Each data object must have the “coordinates” property of type GeoPoint.