flutter - 调用 Geocoder.local.findAddressesFromCoordinates 时发生 PlatformException

标签 flutter dart geolocation latitude-longitude geocoder

如何将位置经纬度转换为格式化地址?我正在尝试使用地理编码器插件,但线路 - await Geocoder.local.findAddressesfromCoordinates(coordinates) 给我一个显示平台异常的错误。这个插件我用了很多次,效果很好,但是这次在我的所有项目中都显示同样的错误,请帮助解决。

var coordinates = new Coordinates(latitude, longitude);
var addresses = 
await Geocoder.local.findAddressesFromCoordinates(coordinates);
var first = addresses.first;
var myAddress = first.addressLine;

** 当我想转换坐标时发现这个错误:
未处理的异常:PlatformException(failed, Failed, null) show error Message **

最佳答案

使用:

await Geocoder.google(your_API_Key).findAddressesFromCoordinates(coordinates);

代替:

await Geocoder.local.findAddressesFromCoordinates(coordinates);

关于flutter - 调用 Geocoder.local.findAddressesFromCoordinates 时发生 PlatformException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57753008/

相关文章:

firebase - 自定义事件根本没有显示在 firebase 仪表板上

ios - 构建iOS应用程序(Flutter)时出错,Android运行顺利。 STRIPEAPPLEPAY Pod 错误

geolocation - 计算传单中两点之间的距离

ios - 由于 iOS 不允许您在后台运行 JS,是否可以让您的应用程序(事件/运行)保持在前台?

android - SharedPreferences 未在发布版本中实例化

firebase - 如何在flutter中访问firestore的某些字段?

flutter - 什么?在 Dart 中做什么?

flutter - 如何在 map 上用颜色发现不同的位置?

dart - 在 Dart 中,给定可空类型 `T?` ,我如何获得不可空类型 `T`

java - 使用JAVA中的geotools在定义的距离(km)内从一条线(GPS坐标)生成多边形