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.

Blocking API

public GeoPoint Backendless.Geo.savePoint( GeoPoint geoPoint ) throws BackendlessException
public GeoPoint Backendless.Geo.savePoint( double latitude, 
                                           double longitude, 
                                           Map<String, Object> metadata ) 
                                                  throws BackendlessException
public GeoPoint Backendless.Geo.savePoint( double latitude, 
                                           double longitude, 
                                           List<String> categories, 
                                           Map<String, Object> metadata ) 
                                                  throws BackendlessException

Non-Blocking API

public GeoPoint Backendless.Geo.savePoint( GeoPoint geoPoint, 
                                           AsyncCallback<GeoPoint> responder ) 
                                                           throws BackendlessException
public GeoPoint Backendless.Geo.savePoint( double latitude, 
                                           double longitude, 
                                           Map<String, Object> metadata, 
                                           AsyncCallback<GeoPoint> responder ) 
                                                         throws BackendlessException
public GeoPoint Backendless.Geo.savePoint( double latitude, 
                                           double longitude, 
                                           List<String> categories, 
                                           Map<String, Object> metadata, 
                                           AsyncCallback<GeoPoint> responder ) 
                                                            throws BackendlessException

where:

Argument                Description
geoPoint a strongly typed object defining the properties of a geo point to add. See the class definition in the "Return Value" section.
latitude latitude of the point to add.
longitude longitude of the point to add.
categories list 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. For the methods without this argument, the point is added to the "Default" category.
metadata metadata associated with the geo point. Must be an arbitrary collection (map) of key/value pairs. Accepted values for this parameter are: String, Number (integer and double), and Data Service objects. Date values must be represented as number in the Unix timestamp format (number of milliseconds since January 1, 1970 at UTC). Learn more about using date in search queries for category, radius, or rectangular area search.
responder a responder object which receives a callback when the method successfully adds the geo point. Applies to the asynchronous methods only.

Return Value

An instance of the GeoPoint class representing the new geo point added to the application's geo location storage. Below is a brief version of the class. The complete source code listing is available in the Backendless github repository.

Example

List<String> categories = new ArrayList<String>()
categories.add( "restaurants" );
categories.add( "cool_places" );

Map<String, Object> meta = new HashMap<String, Object>();
meta.put( "name", "Eatzi's" );

Backendless.Geo.savePoint( 32.81, -96.80, categories, meta, 
                               new AsyncCallback<GeoPoint>()
  {
    @Override
    public void handleResponse( GeoPoint geoPoint )
    {
      Log.i( "MYAPP", geoPoint.getObjectId() );
    }

    @Override
    public void handleFault( BackendlessFault backendlessFault )
    {

    }
  });
}