Google Places API:如何使用多种类型? [英] Google Places API: How to use multiple types?
问题描述
我需要一个可返回评分,照片,开启/关闭时间等的POI API,并且我认为Google Places API似乎可以做我想做的事,但我在过滤时遇到了一些问题:我想使用自动完成功能多种类型的过滤。
这是我的:
var map;
var selectAttractionAutocomplete;
var selectCityAutocompleteOptions = {
types:['(cities)']
};
map = new google.maps.Map(document.getElementById('map-canvas'),{
center:new google.maps.LatLng(-33.8665433,151.1956316),
zoom:15
});
var inputsearchedCity = document.getElementById('input-searching-city');
selectCityAutocomplete = new google.maps.places.Autocomplete(inputsearchedCity,selectCityAutocompleteOptions);
selectCityAutocomplete.bindTo('bounds',map);
google.maps.event.addListener(selectCityAutocomplete,'place_changed',function(){
console.log(selectCityAutocomplete.getPlace());
});
我怎样才能使用多种类型?
我尝试过管道,逗号,括号......没有任何工作:
var selectCityAutocompleteOptions = {
types:[ 'cities | point_of_interest']
};
据 Google文档, point_of_interest
属于类型2,类型过滤器不支持在地点搜索中,或者在添加地点时在类型属性中。
I need a POI API that returns ratings, photos, opening/closing times, etc and I thought Google Places API seemed to do what I want, but I am having some trouble with filtering: I want to use the autocomplete feature with multiple types for filtering.
Here is what I have:
var map;
var selectAttractionAutocomplete;
var selectCityAutocompleteOptions = {
types: ['(cities)']
};
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(-33.8665433, 151.1956316),
zoom: 15
});
var inputsearchedCity = document.getElementById('input-searched-city');
selectCityAutocomplete = new google.maps.places.Autocomplete(inputsearchedCity, selectCityAutocompleteOptions);
selectCityAutocomplete.bindTo('bounds', map);
google.maps.event.addListener(selectCityAutocomplete, 'place_changed', function () {
console.log(selectCityAutocomplete.getPlace());
});
How can I use multiple types?
I have tried pipes, commas, brackets... nothing works:
var selectCityAutocompleteOptions = {
types: ['cities|point_of_interest']
};
According to Google Documentation, point_of_interest
is of type 2, which are not supported in the types filter of a place search, or in the types property when adding a place.
这篇关于Google Places API:如何使用多种类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!