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.business.list() - Global ordering point and geo area are used to sort and filter Locations and Offers
  • lmgClient.business.get() - Global ordering point and geo area are used to sort and filter Business' Locations and Offers
  • lmgClient.collection.list() - Global ordering point and geo area are used to sort and filter Locations
  • lmgClient.collection.business.list() - Global ordering point and geo area are used to sort and filter Locations and Offers
  • lmgClient.location.list() - Global ordering point and geo area are used to sort and filter Locations

Setting a location content filter

The orderingPoint is a LatLng ({ latitude: Number, longitude: Number }) from which results are sorted nearest to farthest. The contextGeoArea is a an array of LatLngs describing an area we are interested in.

Set ordering point

lmgClient.setOrderingPoint({ latitude: 49.8996925, longitude: -119.4546625 });

Set context geo area

lmgClient.setContextGeoArea([
{ latitude: 49.8996925, longitude: -119.4546625 },
{ latitude: 49.0, longitude: -119.4546625 },
{ latitude: 49.0, longitude: -119.0 },
{ latitude: 49.8996925, longitude: -119.4546625 }
]);

Note that this list is required to be a closed area (ie, the last point in the list should usually be the same as the first point) The list of points is required to be an an anti clockwise direction. |

Set context geo area as circle

lmgClient.setContextGeoCircle(
{ latitude: 49.8996925, longitude: -119.4546625 }, // center
5000 // radius in meters
);

Clearing the content filter

lmgClient.setOrderingPoint(null);
lmgClient.setContextGeoArea(null);