【发布时间】:2021-12-15 09:51:02
【问题描述】:
当尝试实施地理编码以从坐标获取地址时,我收到此错误
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(NOT_FOUND, No address information found for supplied coordinates (latitude: 23.837739, longitude: 90.366290)., null, null)
我从坐标中获取地址的函数
Future<void> GetAddressFromLatLong(Position position) async {
print("PlaceMarks:");
List<Placemark> placemarks =
await placemarkFromCoordinates(position.latitude, position.longitude);
print("P:" + placemarks.toString());
Placemark place = placemarks[0];
Address =
'${place.street}, ${place.subLocality}, ${place.locality}, ${place.postalCode}, ${place.country}';
setState(() {
Address =
'${place.street}, ${place.subLocality}, ${place.locality}, ${place.postalCode}, ${place.country}';
});
}
如何使用 Google Cloud Platform 的地理编码 API? Geocoding Flutter Package 是否使用了这个 API?
使用 Flutter v2.5.3 并启用 null 安全
【问题讨论】:
-
使用 long 和 lat 时 - 我通常会仔细检查两件事 - 我通过使用一些简单的代码来检索变量来确保我没有权限问题,然后我还硬编码了一些 long 和 lat并通过全局变量传递它们。通常在使用这两个时所有问题都会消失,或者在此过程中您会收到更有用的错误消息。我的 2 美分 - 祝你好运
标签: flutter google-cloud-platform geocoding