fromLatLng method

Future<GeocodeResponse> fromLatLng(
  1. double latitude,
  2. double longitude, {
  3. String? apiKey,
  4. String? language,
  5. String? region,
  6. String? locationType,
})

Implementation

Future<GeocodeResponse> fromLatLng(
  double latitude,
  double longitude, {
  String? apiKey,
  String? language,
  String? region,
  String? locationType,
}) async {
  final fRegion = region ?? _region;
  final fLocationType = locationType ?? _locationType;

  final qp = <String, dynamic>{
    'latlng': '$latitude,$longitude',
    if (language != null) 'language': language,
    if (fRegion != null) 'region': fRegion,
    if (fLocationType != null) 'location_type': fLocationType,
  };

  try {
    final data = await doGet(
      path: '/maps/api/geocode/json',
      params: qp,
    );
    return GeocodeResponse.fromMap(data);
  } catch (error) {
    final gr = GeocodeResponse.fromError(error.toString());
    return gr;
  }
}