Support Topics Documentation Slack YouTube Blog

Codeless and spatial data

how can i retrieve data using the spatial data and include the distance in the result for each data object?

Hello @mohammad_altoiher

See documentation - - distanceOnSphere Operator

// search in radius - calculates the distance between the value in the column (first argument) and the point in the second argument
distanceOnSphere( spatialColumnName, ‘POINT as WKT’ )

// calculate the distance between the point in spatialColumnNameFrom and the point in spatialColumnNameTo
distanceOnSphere( spatialColumnNameFrom, spatialColumnNameTo )

i tried that but i get the objects data with no distance.
im using distanceOnSphere(store_location, 'POINT(24.5165147-43.9238434)') <= 100000

Try add ‘,’ between lat and long = distanceOnSphere(store_location, ‘POINT(24.5165147**,** -43.9238434)’)

@Vladimir_Yalovy, there is no comma in the WKT definition of a POINT. There must be space between the coordinates though.

i get the data objects with my first query fine but i dont get the distance or know the sorting with the query (i want by the closest)

There must be space between the coordinates in the POINT definition:

distanceOnSphere(store_location, ‘POINT(24.5165147 -43.9238434)’)

with space or without i still get the same results.

results are data objects with not distance or sort by distance

Maybe there are no objects that match that criteria?

then i should not get any results right?


but i get results like i normally get with load table objects

    "stores": [
            "___jsonclass": "store",
            "website": null,
            "address": null,
            "lng": "42.5182113",
            "chain_store": false,
            "created": 1576177568000,
            "rating": null,
            "icon": "",
            "mobile": null,
            "instagram": null,
            "ownerId": null,
            "twitter": null,
            "instagram_update": null,
            "phone": "059 000 1718",
            "name": "زين",
            "___class": "store",
            "twitter_account": null,
            "updated": 1581008912554,
            "objectId": "18.2204797-42.5182113",
            "lat": "18.2204797",
            "store_location": {
                "coordinates": [
                "type": "Point"
            "photo_icon": null,
            "desc": "شركة إتصالات"

with geo points we get the distance and we can sort with the distance also.
how can we do this with the spatial data?

Make sure the same points are stored in the database in a column of type POINT, then use a query to load data.

sorry i didn’t get what you mean. :slight_smile:

im getting the user location from my app and passing it to the API as a parameter, is there something i should do other than that?

To make it productive, let’s focus on the Backendless side of things. If you believe it is not working properly, please share with us:

  1. the query you’re making
  2. what kind of result you’re expecting
  3. what kind of result are you getting



  • my query : distanceOnSphere(store_location, 'POINT(24.710521 46.714670)') <= 1000
  • the result are a list of the data objects in the area.
  • my expected results are the list of data object in the area plus the distance for each data object to the POINT in the query. ex "distance": 159.051

If you use Codeless, then in the properties element, add a list with the following string element:

distanceOnSphere(store_location, 'POINT(24.710521 46.714670)') as distance

This will return a property named distance that has the value.

adding that to the properties i get no result from the query

“stores”: []

What’s your application ID?


i tried adding this to the properties

1+1 as distance

and it did add the property to the results

“stores”: [
“___jsonclass”: “store”,
“distance”: 2,
“___class”: “store”,
“objectId”: “18.2204797-42.5182113”