setAroundLatLngViaIP method
AroundLatLngViaIP
Search for entries around a given location automatically computed from the requester’s IP address. By computing a central geolocation (from an IP), this has 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 using the end user’s IP to define a central axis point of a circle in geo-coordinates.
- Algolia automatically calculates the size of the circular radius around this central axis.
- To control the precise size of the radius, you would use
aroundRadius
. - To control a minimum size, you would use
minimumAroundRadius
.
- To control the precise size of the radius, you would use
- If you are sending the request from your servers, you must set the X-Forwarded-For HTTP header with the front-end user’s IP address for it to be used as the basis for the computation of the search location.
- Note: This setting differs from
aroundLatLng
, which allows you to specify the exact latitude and longitude of the center of the circle. - This parameter will be ignored if used along with
insideBoundingBox
orinsidePolygon
- We currently only support IPv4 addresses. If the end user has an IPv6 address, this parameter won’t work as intended.
Source: Learn more
Implementation
AlgoliaQuery setAroundLatLngViaIP(bool value) {
assert(!_parameters.containsKey('aroundLatLngViaIP'));
return _copyWithParameters(<String, dynamic>{'aroundLatLngViaIP': value});
}