强制 flutter_google_places 在使用 GooglePlacesAutocompleteWidget 时仅显示城市
Force flutter_google_places to only display cities when using GooglePlacesAutocompleteWidget
我正在使用 flutter_google_places 小工具搜索城市。
我已经尝试了小部件提供的自动完成示例,它运行良好。但是,例如,当我输入 "Paris" 时,我会得到很多巴黎地点的结果(巴黎、巴黎机场、巴黎世博会等)。
我只需要我的应用程序中的城市。因此,例如,当输入 "Paris" 时,我只想输入“Paris (France)”、“Paris (Texas)”、“Paris (Tennessee)”等
我还没有找到如何应用 "cities" 过滤器。
这是 Javascript 中的等价物:
var input = document.getElementById('searchField');
var options = {
types: ['(cities)']
};
autocomplete = new google.maps.places.Autocomplete(input, options);
有什么想法吗?
如果您使用此示例:https://github.com/fluttercommunity/flutter_google_places/blob/master/example/lib/main.dart
应该做
CustomSearchScaffold()
: super(
apiKey: kGoogleApiKey,
sessionToken: Uuid().generateV4(),
language: "en",
components: [Component(Component.country, "uk")],
types: ["(cities)"], // or cities
);
我正在使用 flutter_google_places 小工具搜索城市。
我已经尝试了小部件提供的自动完成示例,它运行良好。但是,例如,当我输入 "Paris" 时,我会得到很多巴黎地点的结果(巴黎、巴黎机场、巴黎世博会等)。
我只需要我的应用程序中的城市。因此,例如,当输入 "Paris" 时,我只想输入“Paris (France)”、“Paris (Texas)”、“Paris (Tennessee)”等
我还没有找到如何应用 "cities" 过滤器。
这是 Javascript 中的等价物:
var input = document.getElementById('searchField');
var options = {
types: ['(cities)']
};
autocomplete = new google.maps.places.Autocomplete(input, options);
有什么想法吗?
如果您使用此示例:https://github.com/fluttercommunity/flutter_google_places/blob/master/example/lib/main.dart
应该做
CustomSearchScaffold()
: super(
apiKey: kGoogleApiKey,
sessionToken: Uuid().generateV4(),
language: "en",
components: [Component(Component.country, "uk")],
types: ["(cities)"], // or cities
);