问题描述
我正在尝试从坐标中获取地标。
我正在为此使用geoLocator
。今天早上工作正常,但是现在,它抛出了平台异常。
PlatformException(IO_ERROR,A network error occurred trying to lookup the supplied coordinates (latitude: <lat>,longitude: <long>).,null)
这是网络错误,但是我的设备已连接到互联网,
首先,我认为Geolocator
软件包中可能存在一些问题,所以我使用了Geocoding
软件包,但是问题仍然存在。
这是地址解析器的错误。
Geocoder getFromLocation --- mService = android.location.ILocationManager$Stub$Proxy@e8c2197,ex = grpc Failed,return results = []
请帮助。
解决方法
尝试添加localeIdentifier
参数。为我工作。我的功能代码会像
List<Placemark> newPlace = await GeocodingPlatform.instance.placemarkFromCoordinates(position.latitude,position.longitude,localeIdentifier: "en");
,
我有同样的问题。 尝试使用另一个模拟器(就像使用其他android或ios设备一样创建另一个模拟器)。 可能是当前正在仿真的设备无法连接到互联网
,尝试在模拟器上擦除数据。 重新启动。
有效。
,请参阅以下flutter_geocoding问题(已关闭):https://github.com/Baseflow/flutter-geocoding/issues/23
提出了两种解决方案:
- 创建一个新的模拟器
- 在模拟器上停止WiFi,重新启动WiFi并让其查找网络(AndroidWiFi)
解决方案2对我有用。
,这主要是由于您的设备位置发生了变化,如果您使用的是 Android 手机等外部设备,那么您应该重新启动设备,它会正常工作。