Skip to main content

Content Filtering and Sorting

Content filters sort requested data by distance from the filter location (typically a geo-coordinate), in a descending order (closest first). They can also limit data by specifying a geographic area for the returned data. The content filter is set globally for the SDK, and it is an optional configuration.

By default the SDK uses device location geo point for sorting if available, and data is not filtered in any way.

Effects of location content filters

Setting content filter affects following method calls:

  • [LMGClient collectionsListProvider] - data provider that filters returned collections if filter geometry specified
  • [LMGClient businessListProvider], [LMGClient collectionBusinessesListProvider] - data provider sorts and filters returned businesses with offers if sorting geo point and filter geometry specified
  • [LMGClient locationsMapProvider] - data provider sorts and filters locations if sorting geo point and filter geometry specified
  • [LMGClient getOfferWithParams:completion:] - sorts locations where offer is available if sorting geopoint specified
  • [LMGClient getBusinessWithParams:completion:] - sorts locations of a business if sorting geopoint specified
  • [LMGMapWireframe mapViewController] - centers on ordering geo point if one is set, otherwise displays current user location

Setting a location content filter

Sorting data by distance

LMGClient.shared().setContentFilterWithBuilder { (LMGContentFilterBuilder) in
LMGContentFilterBuilder
.setGeoPointForOrdering(CLLocationCoordinate2D(latitude: lat, longitude: lon))
}

Filtering and sorting data using point and radius around it

[[LMGClient shared] setContentFilterWithBuilder:^(LMGContentFilterBuilder * _Nonnull builder) {
[builder setGeoPointForOrdering:CLLocationCoordinate2DMake([latitude doubleValue], [longitude doubleValue]) showContentInRadius:10000];
}];

Filtering and sorting data using custom geometry

[[LMGClient shared] setContentFilterWithBuilder:^(LMGContentFilterBuilder * _Nonnull builder) {
NSArray<CLLocation *> *geometry = @[];
[builder setGeoPointForOrdering:CLLocationCoordinate2DMake([latitude doubleValue], [longitude doubleValue]) showContentInArea:geometry];
}];

Clearing the content filter

LMGClient.shared().setContentFilterWithBuilder(nil)