Skip to content

Retrieving Geo Categories

This API retrieves a list of all the application's geo categories.

Method:

Future<List<GeoCategory>> Backendless.geo.getCategories();

Return Value

A list of the GeoCategory objects. Each GeoCategory instance represents a category with the properties of objectId, name and number of geo points in it.

class GeoCategory extends BaseGeoCategory implements Comparable<GeoCategory> {
  String objectId;
  String name;
  int size;

  // returns objectId assigned to the category
  String get id => objectId;

  bool operator ==(o) =>
      o is GeoCategory && o.name == name && o.objectId == objectId;

  @override
  int get hashCode => hashValues(name, objectId);

  @override
  String toString() => "GeoCategory{name='$name', size=$size}";

  @override
  int compareTo(GeoCategory other) {
    if (this == other) return 0;

    int nameDiff = this.name == null
        ? (other.name == null ? 0 : -1)
        : this.name.compareTo(other.name);
    if (nameDiff != 0) return nameDiff;

    return this.size - other.size;
  }
}

Example

Backendless.geo.getCategories().then((categories) {
  print("Categories: $categories");
});