Flutter 是否可以使用flatter在Google Maps Autocomplete上只显示特定的位置?
我想创建一个搜索栏使用颤振和谷歌地图Api。用户应仅选择特定地点,例如学校。我怎样才能做到这一点?我试着用下面的代码使用Flutter 是否可以使用flatter在Google Maps Autocomplete上只显示特定的位置?,flutter,maps,google-places-api,Flutter,Maps,Google Places Api,我想创建一个搜索栏使用颤振和谷歌地图Api。用户应仅选择特定地点,例如学校。我怎样才能做到这一点?我试着用下面的代码使用flatter\u google\u places和google\u maps\u webservice return Scaffold( body: Container( alignment: Alignment.center, child: RaisedButton( onPr
flatter\u google\u places
和google\u maps\u webservice
return Scaffold(
body: Container(
alignment: Alignment.center,
child: RaisedButton(
onPressed: () async {
Prediction p = await PlacesAutocomplete.show(
context: context,
apiKey: kGoogleApiKey,
language: 'de',
);
displayPrediction(p);
},
child: Text('Find address'),
)
)
);
}
Future<Null> displayPrediction(Prediction p) async {
if (p != null) {
PlacesDetailsResponse detail =
await _places.getDetailsByPlaceId(p.placeId);
var placeId = p.placeId;
double lat = detail.result.geometry.location.lat;
double lng = detail.result.geometry.location.lng;
var address = await Geocoder.local.findAddressesFromQuery(p.description);
print(lat);
print(lng);
}
返回脚手架(
主体:容器(
对齐:对齐.center,
孩子:升起按钮(
onPressed:()异步{
预测p=等待地点SautoComplete.show(
上下文:上下文,
apiKey:kGoogleApiKey,
语言:'德',
);
显示预测(p);
},
子项:文本(“查找地址”),
)
)
);
}
未来显示预测(预测p)异步{
如果(p!=null){
位置细节响应细节=
等待地点。getDetailsByPlaceId(p.placeId);
var placeId=p.placeId;
双lat=detail.result.geometry.location.lat;
双液化天然气=详图.result.geometry.location.lng;
var address=await Geocoder.local.findAddressesFromQuery(p.description);
打印(lat);
印刷品(液化天然气);
}
此代码显示Google Maps Api的所有结果。如何将结果限制为仅显示特定位置,如上面提到的学校
提前谢谢