reverseGeocode method
ReverseGeocode converts geographic coordinates into a
human-readable address or place. You can obtain address component, and
other related information such as place type, category, street
information. The Reverse Geocode API supports filtering to on place type
so that you can refine result based on your need. Also, The Reverse
Geocode API can also provide additional features such as time zone
information and the inclusion of political views.
For more information, see Reverse Geocode in the Amazon Location Service Developer Guide.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ThrottlingException.
May throw ValidationException.
Parameter queryPosition :
The position in World Geodetic System (WGS 84) format: [longitude,
latitude] for which you are querying nearby results for. Results closer
to the position will be ranked higher then results further away from the
position
Parameter additionalFeatures :
A list of optional additional parameters, such as time zone that can be
requested for each result. For GrabMaps
customers, ap-southeast-1 and ap-southeast-5
regions support only the TimeZone value.
Parameter filter :
A structure which contains a set of inclusion/exclusion properties that
results must possess in order to be returned as a result.
Parameter heading :
The heading in degrees from true north in a navigation context. The
heading is measured as the angle clockwise from the North direction.
Example: North is 0 degrees, East is 90 degrees,
South is 180 degrees, and West is 270 degrees.
Parameter intendedUse :
Indicates if the query results will be persisted in customer
infrastructure. Defaults to SingleUse (not stored).
Parameter key :
Optional: The API key to be used for authorization. Either an API key or
valid SigV4 signature must be provided when making a request.
Parameter language :
A list of BCP
47 compliant language codes for the results to be rendered in. If
there is no data for the result in the requested language, data will be
returned in the default language for the entry. For GrabMaps
customers, ap-southeast-1 and ap-southeast-5
regions support only the following codes: en, id, km, lo, ms, my,
pt, th, tl, vi, zh
Parameter maxResults :
An optional limit for the number of results returned in a single call.
Default value: 1
Parameter politicalView :
The alpha-2 or alpha-3 character code for the political view of a country.
The political view applies to the results of the request to represent
unresolved territorial claims through the point of view of the specified
country. Not supported in ap-southeast-1 and
ap-southeast-5 regions for GrabMaps
customers.
Parameter queryRadius :
The maximum distance in meters from the QueryPosition from which a result
will be returned. For GrabMaps
customers, ap-southeast-1 and ap-southeast-5
regions support only up to a maximum value of 100,000.
Implementation
Future<ReverseGeocodeResponse> reverseGeocode({
required List<double> queryPosition,
List<ReverseGeocodeAdditionalFeature>? additionalFeatures,
ReverseGeocodeFilter? filter,
double? heading,
ReverseGeocodeIntendedUse? intendedUse,
String? key,
String? language,
int? maxResults,
String? politicalView,
int? queryRadius,
}) async {
_s.validateNumRange(
'heading',
heading,
0.0,
360.0,
);
_s.validateNumRange(
'queryRadius',
queryRadius,
0,
4294967295,
);
final $query = <String, List<String>>{
if (key != null) 'key': [key],
};
final $payload = <String, dynamic>{
'QueryPosition': queryPosition,
if (additionalFeatures != null)
'AdditionalFeatures': additionalFeatures.map((e) => e.value).toList(),
if (filter != null) 'Filter': filter,
if (heading != null) 'Heading': heading,
if (intendedUse != null) 'IntendedUse': intendedUse.value,
if (language != null) 'Language': language,
if (maxResults != null) 'MaxResults': maxResults,
if (politicalView != null) 'PoliticalView': politicalView,
if (queryRadius != null) 'QueryRadius': queryRadius,
};
final response = await _protocol.sendRaw(
payload: $payload,
method: 'POST',
requestUri: '/v2/reverse-geocode',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
final $json = await _s.jsonFromResponse(response);
return ReverseGeocodeResponse(
resultItems: ($json['ResultItems'] as List?)
?.nonNulls
.map((e) =>
ReverseGeocodeResultItem.fromJson(e as Map<String, dynamic>))
.toList(),
pricingBucket: _s.extractHeaderStringValue(
response.headers, 'x-amz-geo-pricing-bucket')!,
);
}