reverseGeoCode method
- double? lat,
- double? lon,
- GeoCoordinates? geoCoordinates,
- ReverseGeoCodeMode mode = ReverseGeoCodeMode.retrieveAddresses,
- int maxResults = 1,
reverseGeoCode retrieves the first address around a specified lat
& long
using a 250 meter radius to retrieve the address.
maxResults
can be given to get the number of the Results
By default value of maxResults
is 1
mode
defines the Reverse GeCoding Mode
ReverseGeoCodeMode.retrieveAddresses Search for the closest street address or addresses
ReverseGeoCodeMode.retrieveAreas Retrieve the administrative area information for the position provided in the request
ReverseGeoCodeMode.retrieveLandmarks Search for landmarks like parks and lakes in the proximity provided in the request
ReverseGeoCodeMode.trackPosition Retrieve street and address information based on a position and bearing
ReverseGeoCodeMode.retrieveAll Search for streets, administrative areas and landmarks. This mode aggregates the results of the three different modes in one call
https://developer.here.com/documentation/geocoder/dev_guide/topics/reading-geocoding-response.html
Implementation
Future<GeoCodeResponse> reverseGeoCode({
double? lat,
double? lon,
GeoCoordinates? geoCoordinates,
ReverseGeoCodeMode mode = ReverseGeoCodeMode.retrieveAddresses,
int maxResults = 1,
}) async {
assert(geoCoordinates != null || (lat != null && lon != null), "You've to provide coordinates");
assert(maxResults <= 1, 'maxResults should be greater than 1');
final headers = _createHeader();
final data = _createMap();
data['prox'] = geoCoordinates == null ? '$lat,$lon' : '${geoCoordinates.latitude},${geoCoordinates.longitude}';
data['mode'] = EnumUtils.getName(mode);
var uri = Uri.https('reverse.geocoder.ls.hereapi.com', '/6.2/reversegeocode.json', data);
final result = await _callHereApi(uri, headers);
return GeoCodeResponse.fromJson(result);
}