reverseLocation static method
Future<FormattedLocation>
reverseLocation({
- required Locale locale,
- ReverseZoom? zoom,
- required LatLng location,
Implementation
static Future<FormattedLocation> reverseLocation({
required Locale locale,
ReverseZoom? zoom,
required LatLng location,
}) async {
var url = Uri.parse("https://nominatim.openstreetmap.org/reverse");
url = url.replace(
queryParameters: {
"lat": location.latitude.toString(),
"lon": location.longitude.toString(),
"format": "jsonv2",
"namedetails": "1",
"accept-language": locale.languageCode,
if (zoom != null) "zoom": zoom.zoom(),
"addressdetails": "1",
"polygon_geojson": "1",
"extratags": "1",
},
);
var response = await http.get(url);
var parsed = jsonDecode(utf8.decode(response.bodyBytes));
return FormattedLocation.fromJson(parsed).copyWith(
lat: location.latitude,
lon: location.longitude,
);
}