Skip to content

Adding a GeoPoint

This API adds a geo point to the backend geo location storage. Once a geo point is added, it becomes searchable through all geopoint search mechanisms supported by Backendless (search in radius, search in a rectangular area, search in a category). At the present moment there are two ways to add geo points: (1) using the API documented below or (2) using the Backendless console's import function.

Method

POST

URL

https://api.backendless.com/<application-id>/<REST-api-key>/geo/points

where:

Argument                Description
<application id> ID of the application which can be obtained from the Manage > App Settings screen of the Backendless Console
<REST-api-key> REST API key of your application. You can get the value from the Manage > App Settings section of the Backendless Console.

Request headers

Content-Type: application/json  
user-token: optional value obtained as a result of the login operation.

where:

Argument                Description
Content-Type Must be set to application/json. This header is mandatory.
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-token is set in the request, the currently logged in user will be assigned to the ownerId property of the user object which is being saved.  Additionally, the operation will be executed with the security policy associated currently logged in user. This means all permissions associated with the user and the roles assigned to the user will be enforced by Backendless.

Request Body

A JSON object representing a geo point.

{  
  "latitude": <latitude>,  
  "longitude": <longitude>,  
  "categories": <categories>,  
  "metadata": <metadata>  
}

where:

Argument                Description
<latitude> a numeric value. Latitude of the geopoint to add.
<longitude> a numeric value. Longitude of the point to add.
<categories> optional parameter. A JSON array of categories the point is added to. If a category does not exist at the time when a point is added, Backendless creates the category and adds the point to it. If the parameter is not present in the request, the point is added to the "Default" category.
<metadata> optional parameter. A JSON object representing the metadata associated with the geo point.

Response Body

A JSON object representing the saved geo point. The object also contains the objectId property assigned by the server. If an error occurs, the response is formatted as described in the Error Handling section.

Example

curl -X POST -H Content-Type:application/json \  
-d "{\"longitude\":20.12, \"latitude\":-60.22, \  
     \"categories\":[\"MisterySpot\"], \"metadata\":{\"foo\":\"bar\"} }" \  
-v "http://api.backendless.com/XXXX-XXXX-XXXX/ZZZZ-ZZZZ-ZZZZ/geo/points?lat=10&lon=20&metadata=%20%7B%20%22foo%22%3A%22bar%22%20%7D"

When the geo point is saved, you can see it in the Backendless console:
added-geopoint.zoom50