问题描述
是否可以使用Google Maps JavaScript API v3在一个位置搜索请求中搜索多个单个关键字?
Is it possible search multiple individual keywords in one place search request using Google Maps JavaScript API v3?
在Google Places API文档中指出,可以使用多个关键字 https: //developers.google.com/places/training/additional-places-features
In the Google Places API documentation it states that multiple keywords can be used https://developers.google.com/places/training/additional-places-features
?keyword=theater+gym
,但这在JavaScript API中不起作用.我试过了:
but this does not work in the JavaScript API. I tried:
function performSearch() {
var request = {
location: map.center,
radius: '500',
keyword: 'theater+gym+tacos',
rankBy: 'distance'
};
service.radarSearch(request, callback);
}
...,并且不会为每个关键字返回位置.有谁知道如何搜索多个关键字?
...and does not return places for each keyword. Does anyone have an idea how to search multiple keywords?
注意:我正在尝试在一个请求中搜索多个单个关键字,而不是带有空格的短语.
Note: I'm trying to search multiple individual keywords in one request not a phrase with spaces.
推荐答案
答案似乎是否"(至少在目前,您可以请求.
It looks like the answer is "no" (at least at the present time, you could request an enhancement on the issue tracker.
一种解决方法是发送三个单独的查询,每个关键字一个.对于3个关键字应该可以,在某些时候您会遇到查询速率限制.
A work around would be to send three separate queries, one for each keyword. Should be OK for 3 keywords, at some point you will run into the query rate limit.
var request = {
location: pyrmont,
radius: 500,
keyword: 'theater'
};
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
var request2 = {
location: pyrmont,
radius: 500,
keyword: 'gym'
};
var service2 = new google.maps.places.PlacesService(map);
service2.nearbySearch(request2, callback);
var request3 = {
location: pyrmont,
radius: 500,
keyword: 'tacos'
};
var service3 = new google.maps.places.PlacesService(map);
service3.nearbySearch(request2, callback);
这篇关于Google Maps API-多个关键字进行就地搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!