setInsideBoundingBox method

AlgoliaQuery setInsideBoundingBox(
  1. List<BoundingBox> value
)

InsideBoundingBox

Search inside a rectangular area (in geo coordinates).

The rectangle is defined by two diagonally opposite points (hereafter p1 and p2), hence by 4 floats: p1Lat, p1Lng, p2Lat, p2Lng.

For example: insideBoundingBox = [ 47.3165, 4.9665, 47.3424, 5.0201 ]

Usage notes

  • You may specify multiple bounding boxes, in which case the search will use the union (OR) of the rectangles. To do this, pass either:
    • more than 4 values (must be a multiple of 4: 8, 12…); example: 47.3165,4.9665,47.3424,5.0201,40.9234,2.1185,38.6430,1.9916; or
    • an list of lists of floats (each inner array must contain exactly 4 values); example: [[47.3165, 4.9665, 47.3424, 5.0201], [40.9234, 2.1185, 38.6430, 1.9916]].
  • aroundLatLng and aroundLatLngViaIP will be ignored if used along with this parameter.
  • Be careful when your coordinates cross over the 180th meridian.

Source: Learn more

Implementation

AlgoliaQuery setInsideBoundingBox(List<BoundingBox> value) {
  assert(value.isNotEmpty, 'value can not be empty');
  assert(!_parameters.containsKey('insideBoundingBox'));
  var list = value.map((v) => [v.p1Lat, v.p1Lng, v.p2Lat, v.p2Lng]).toList();
  return _copyWithParameters(<String, dynamic>{'insideBoundingBox': list});
}