getCoordinates method
- String address
Converts a given address into geographic coordinates (latitude and longitude).
Returns a MyLatLng object containing the latitude and longitude of the first location found for the given address. If the address cannot be geocoded, it returns a MyLatLng object with coordinates (0.0, 0.0).
- Parameter address: The address to be converted into coordinates.
- Returns: A MyLatLng object containing the latitude and longitude.
Implementation
Future<MyLatLng> getCoordinates(String address) async {
try {
List<Location> locations = await locationFromAddress(address);
Location location = locations.first;
return MyLatLng(location.latitude, location.longitude);
} catch (e) {
print('error geocoding failed to get coordinates: ${e}');
return MyLatLng(0.0, 0.0);
}
}