flutter - Google Places AutoComplete 搜索时不显示地址
问题描述
我目前正在开发一个应用程序,该应用程序使用 google 地方自动完成功能来查找世界各地的地址。我已经通过以下方式实现了它:
Position currentPosition;
var placeId, address;
double lat, lng;
getCurrentLocation(){
final Geolocator geolocator = Geolocator()..forceAndroidLocationManager;
geolocator
.getCurrentPosition(desiredAccuracy: LocationAccuracy.best)
.then((Position position){
setState(() {
currentPosition = position;
});
}).catchError((e){
print(e);
});
}
Future<Null> displayPrediction(Prediction p) async {
if (p != null) {
PlacesDetailsResponse detail = await _places.getDetailsByPlaceId(p.placeId);
placeId = p.placeId;
lat = detail.result.geometry.location.lat;
lng = detail.result.geometry.location.lng;
address = await Geocoder.local.findAddressesFromQuery(p.description);
}
}
onPressed: () async {
print(currentPosition.latitude);
print(currentPosition.longitude);
Prediction prediction = await PlacesAutocomplete.show(
context: context,
apiKey: googleApiKey,
location: Location(currentPosition.latitude, currentPosition.longitude),
radius: 100000000,
mode: Mode.overlay,
language: "en",
);
但是,每当我在搜索栏中输入内容时,我都不会收到任何自动完成的结果,而且我不知道为什么(附图)。如果有什么不同,我使用的是 iOS 模拟器。我还没有在安卓上测试过。任何帮助将非常感激。
解决方案
推荐阅读
- wordpress - 带有 $wpdb->get_results 的 WordPress 自定义分页
- php - 在php中为每个添加总和
- php - 如何在 PHP Codeigniter 中发送动态消息(SMS)
- spring-kafka - 为每个 KafkaTemplate 指定 client.id
- python - 使用 Python 查找特定的重叠模式
- emv - 解释 EMV MDK 密钥 Enc MAC AC
- javascript - 引导表跟随 div 内的滚动
- angular - 在按钮单击时选择 PrimeNg 多选选项,Angular
- javascript - Javascript Regex - 从标签字符串中获取特定的 html 标签
- java - 未经授权的用户访问某些 url