Google Places API:如何使用多种类型?

编程入门 行业动态 更新时间:2024-10-28 20:27:38
本文介绍了Google Places API:如何使用多种类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要一个可返回评分,照片,开启/关闭时间等的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_interestis 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:如何使用多种类型?

本文发布于:2023-11-15 09:36:32,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   多种   类型   Google   Places

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!