API Reference / API Parameters / aroundLatLng
Feb. 12, 2019
Type: string
Engine default: null
Parameter syntax
'aroundLatLng' => 'latitude, longitude' // 2 floats

Can be used in these methods:

About this parameter

Search for entries around a central geolocation, enabling a geo search within a circular area.

By defining this central point, there are three consequences:

  • a radius / circle is computed automatically, based on the density of the records near the point defined by this setting
  • only records that fall within the bounds of the circle are returned
  • records are ranked according to the distance from the center of the circle

Usage notes:

  • With this setting, you are defining a central point of a circle, whose geo-coordinates are expressed as two floats separated by a comma.

  • Note: This setting differs from aroundLatLngViaIP, which uses the end-user’s IP to determine the geo-coordinates.

  • This parameter will be ignored if used along with insideBoundingBox or insidePolygon

  • To control the maximum size of the radius, you would use aroundRadius.

  • To control the minimum size, you would use minimumAroundRadius.

  • The size of this radius depends on the density of the area around the central point. If there are a large number of hits close to the central point, the radius can be small. The less hits near the center, the larger the radius will be.

  • Note: If the results returned are less than the number of hits per page (hitsPerPage), then the number returned will be less than the hitsPerPage. For example, if you recieve 15 results, you could still see a larger number of hits per page, such as hitsPerPage=20.

Examples

Search around a position

1
2
3
$results = $index->search('query', [
  'aroundLatLng' => '40.71, -74.01'
]);

Did you find this page helpful?