Flutter Google Places 自动填充仅适用于地区和子地区
我想通过 Google Places API 获取仅针对地区和次地区的建议,仅此而已。
我阅读了 Google Places 网站上的文档,看来这是不可能的。所有搜索还提供有关省份、国家、邮政编码等的建议。
请在下面找到我的代码片段:
void getSuggestion(String input) async {
String kPLACES_API_KEY = "API_KEY";
String type = '(region)';
String baseURL =
'https://maps.googleapis.com/maps/api/place/autocomplete/json';
String request =
'$baseURL?input=$input&key=$kPLACES_API_KEY&sessiontoken=$_sessionToken&types=$type';
var response = await http.get(Uri.parse(request));
if (response.statusCode == 200) {
setState(() {
_placeList = json.decode(response.body)['predictions'];
});
} else {
throw Exception('Failed to load predictions');
}
}
对此有任何解决方法吗?
I want to get the suggestions through Google Places API only for Localities and Sublocalities and nothing else.
I read the documentation on the Google Places Website and it seems that this is impossible. All searches also give suggestions on Provinces, Countries, Postal Codes and etc.
Please find my snippet below:
void getSuggestion(String input) async {
String kPLACES_API_KEY = "API_KEY";
String type = '(region)';
String baseURL =
'https://maps.googleapis.com/maps/api/place/autocomplete/json';
String request =
'$baseURL?input=$input&key=$kPLACES_API_KEY&sessiontoken=$_sessionToken&types=$type';
var response = await http.get(Uri.parse(request));
if (response.statusCode == 200) {
setState(() {
_placeList = json.decode(response.body)['predictions'];
});
} else {
throw Exception('Failed to load predictions');
}
}
Is there any workaround for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)