Cyb*_*kie 7 javascript google-maps google-maps-api-3
是否可以使用Google Maps JavaScript API v3在一个地方搜索请求中搜索多个单独的关键字?
在Google Places API文档中,它指出可以使用多个关键字https://developers.google.com/places/training/additional-places-features
?keyword=theater+gym
但这在JavaScript API中不起作用.我试过了:
function performSearch() {
var request = {
location: map.center,
radius: '500',
keyword: 'theater+gym+tacos',
rankBy: 'distance'
};
service.radarSearch(request, callback);
}
Run Code Online (Sandbox Code Playgroud)
...并且不会为每个关键字返回位置.有没有人知道如何搜索多个关键字?
注意:我正在尝试在一个请求中搜索多个单独的关键字,而不是使用空格的短语.
geo*_*zip 10
看起来答案是"不"(至少在目前,您可以要求对问题跟踪器进行增强.
解决方法是发送三个单独的查询,每个查询对应一个关键字.对于3个关键字应该没问题,在某些时候你会遇到查询速率限制.
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);
Run Code Online (Sandbox Code Playgroud)
小智 7
使用Google place API,使布尔搜索看起来像这样:
var request = {
location: /*your location*/,
radius: /*your radius*/,
keyword: "(cinema) OR (theater)"
};
Run Code Online (Sandbox Code Playgroud)
你可以使用OR,AND但尊重案例!!
再见,netoale
| 归档时间: |
|
| 查看次数: |
11534 次 |
| 最近记录: |