Skip to content

Adding a Geo Category

This API creates a geo category. A geo category is a logical grouping of geo points. Category name may contain the following literals: a-z, A-Z, numbers 0-9 and the underscore (_ ) character. The name must start with a literal. Category names can be inspected using Backendless Console (see the image below) or using the API call retrieving a list of categories.

Adding Categories in Console

Backendless Console supports adding a category via the graphical interface. To create a category:

  1. Login to Backendless Console and select your app/backend.
  2. Click the Geolocation icon in the menu on the left.
  3. Use the "plus" icon located above the section containing the list of categories:
    create-new-geo-cat

  4. Enter the category name in the popup and click "Save".


Adding Categories with the API

- (void)addCategoryWithCategoryName:(NSString * _Nonnull)categoryName responseHandler:^(GeoCategory * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func addCategory(categoryName: String, responseHandler: ((GeoCategory) -> Void)!, errorHandler: ((Fault) -> Void)!)

where:

Argument                Description
categoryName name of the category to create.

Return Value

An instance of the GeoCategory class representing the new category with the properties for category's objectId, name and size, which represents the number of geopoints in the category.

Example

[Backendless.shared.geo addCategoryWithCategoryName:@"my_category_name" responseHandler:^(GeoCategory *category) {
    NSLog(@"Category has been saved: %@", category);
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];
Backendless.shared.geo.addCategory(categoryName: "my_category_name", responseHandler: { category in
    print("Category has been saved: \(category)")
}, errorHandler: { fault in
    print("Error: \(fault.message ?? "")")
})