fromAddress method

Future<GeocodeResponse> fromAddress(
  1. String address, {
  2. String? apiKey,
  3. String? language,
  4. String? region,
  5. String? locationType,
})

Implementation

Future<GeocodeResponse> fromAddress(
  String address, {
  String? apiKey,
  String? language,
  String? region,
  String? locationType,
}) async {
  final fRegion = region ?? _region;
  final fLocationType = locationType ?? _locationType;

  final qp = <String, dynamic>{
    'address': address,
    if (apiKey != null) 'key': apiKey,
    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;
  }
}