API Reference / API Parameters / insideBoundingBox
Feb. 26, 2019

insideBoundingBox

Type: list of floats
Engine default: null
Parameter syntax
'insideBoundingBox' => [
  [
    point1_lat,
    point1_lng,
    point2_lat,
    point2_lng
  ],
  [ ... ] // you can search in multiple rectangles
]

Can be used in these methods:

About this parameter

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.

Examples

Search inside a rectangular area

1
2
3
4
5
6
7
8
9
10
$boundingBox = [
  46.650828100116044, // p1Lat
  7.123046875, // p1Lng
  45.17210966999772, // p2Lat
  1.009765625 // p2Lng
];

$results = $index->search('query', [
  'insideBoundingBox' => [$boundingBox]
]);

Search inside multiple rectangular areas

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$boundingBox1 = [
  46.650828100116044, // p1Lat
  7.123046875, // p1Lng
  45.17210966999772, // p2Lat
  1.009765625, // p2Lng
];

$boundingBox2 = [
  49.62625916704081, // p1Lat
  4.6181640625 // p1Lng
  47.715070300900194 // p2Lat
  0.482421875 // p2Lng
];

$results = $index->search('query', [
  'insideBoundingBox' => [
    $boundingBox1,
    $boundingBox2
  ]
]);

Did you find this page helpful?