geoCode method
geoCode can be used to retrieves the latitude, longitude and complete address details
based on the searchText
provided
Implementation
Future<GeoCodeResponse> geoCode({
String? country,
String? state,
String? county,
String? city,
String? district,
String? street,
String? houseNumberOrName,
String? postalCode,
String? searchtext,
}) async {
assert(
country != null ||
state != null ||
county != null ||
city != null ||
district != null ||
street != null ||
houseNumberOrName != null ||
postalCode != null ||
searchtext != null,
'At least one argument is required.');
final headers = _createHeader();
final data = _createMap();
if (country != null) data['country'] = country;
if (state != null) data['state'] = state;
if (county != null) data['county'] = county;
if (city != null) data['city'] = city;
if (district != null) data['district'] = district;
if (street != null) data['street'] = street;
if (houseNumberOrName != null) data['housenumber'] = houseNumberOrName;
if (postalCode != null) data['postalCode'] = postalCode;
if (searchtext != null) data['searchtext'] = searchtext;
var uri = Uri.https('geocoder.ls.hereapi.com', '/6.2/geocode.json', data);
final result = await _callHereApi(uri, headers);
return GeoCodeResponse.fromJson(result);
}