地理编码器 getFromLocation 失败

Mad*_*ahi 5 android geolocation dart firebase flutter

我正在尝试从坐标中获取地标。

我正在用geoLocator这个。今天早上工作正常,但现在抛出平台异常。

PlatformException(IO_ERROR, A network error occurred trying to lookup the supplied coordinates (latitude: <lat>, longitude: <long>)., null)
Run Code Online (Sandbox Code Playgroud)

它说这是网络错误,但我的设备已连接到互联网,

首先,我认为包可能有问题Geolocator,所以我使用了Geocoding包,但问题仍然存在。

这是地理编码器的错误。

Geocoder getFromLocation --- mService = android.location.ILocationManager$Stub$Proxy@e8c2197, ex = grpc failed, return results = []
Run Code Online (Sandbox Code Playgroud)

请帮忙。

小智 8

尝试添加localeIdentifier参数。对我有用。我的功能代码将是这样的

List<Placemark> newPlace = await GeocodingPlatform.instance.placemarkFromCoordinates(position.latitude, position.longitude,localeIdentifier: "en");
Run Code Online (Sandbox Code Playgroud)


Gra*_*amD 7

请参阅此 flutter_geocoding 问题(已关闭):https ://github.com/Baseflow/flutter-geocoding/issues/23

提出了两种解决方案:

  1. 创建一个新的模拟器
  2. 停止模拟器上的WiFi,重新启动WiFi并让它找到网络(AndroidWiFi)

解决方案 2 对我有用。

  • 谢谢,解决方案2也对我有用 (2认同)

Mat*_*tia 6

尝试擦除模拟器上的数据。重新启动它。

有用。