我正在尝试搜索地址,然后尝试通过Geolocator获取该位置的位置,然后尝试将相机位置设置为该位置,但是它不起作用。
我发现了Geolocator的两种方法的一些例外。 Geolodator的所有其他方法对我来说都很好:
1。 Geolocator()。placemarkFromAddress()显示:
PlatformException(ERROR_GEOCODING_ADDRESS,服务不可用,null)
2。 Geolocator()。placemarkFromCoordinates()显示:
PlatformException(ERROR_GEOCODING_COORDINATES,服务不可用,null)
我正在尝试的代码:
try {
List<Placemark> placemark = await Geolocator().placemarkFromAddress(searchAddress);
Placemark newPlace = placemark[0];
controller.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
target: LatLng(newPlace.position.latitude,newPlace.position.longitude),
zoom: 15.0,
)));
}catch(e){
print(e);
}
我从堆栈溢出中的另一个问题here中找到了该问题的解决方案。