getAddressFromLatLng function
Implementation
Future<String> getAddressFromLatLng(LatLng pos) async {
PlacesSearchResponse response;
if (urlServerBackend.isNotEmpty){
var t = await _placesSearchNearbyWithRadius(pos.latitude, pos.longitude);
if (t == null)
return "";
response = t;
}else {
if (kIsWeb)
return "";
GoogleMapsPlaces places = GoogleMapsPlaces(apiKey: appSettings.googleMapApiKey);
response = await places.searchNearbyWithRadius(Location(lat: pos.latitude, lng: pos.longitude), 20);
}
if (response.results.isEmpty)
return "";
if (!response.isOkay)
return "${response.errorMessage}";
var _textAddress = "";
if (response.results.isNotEmpty) {
for (var item in response.results)
if (item.vicinity != null)
if (item.vicinity!.length > _textAddress.length)
_textAddress = item.vicinity!;
}
return _textAddress;
}