放置 API 文本搜索与附近搜索
Places API textSearch vs nearbySearch
在这里,我有一个演示,它使用nearbySearch
来搜索框中的对象(route boxer实用程序):
http://www.geocodezip.com/v3_SO_RouteBoxerPlaces.html法典:
function findPlaces(boxes,searchIndex) {
var request = {
bounds: boxes[searchIndex],
types: ["gas_station"]
};
// alert(request.bounds);
service.radarSearch(request, function (results, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert("Request["+searchIndex+"] failed: "+status);
return;
}
// alert(results.length);
document.getElementById('side_bar').innerHTML += "bounds["+searchIndex+"] returns "+results.length+" results<br>"
for (var i = 0, result; result = results[i]; i++) {
var marker = createMarker(result);
}
searchIndex++;
if (searchIndex < boxes.length)
findPlaces(boxes,searchIndex);
});
}
现在,当我尝试使用textSearch
而不是nearbySearch
时,我看到带有文本搜索和查询的代码搜索框外的对象......http://jsbin.com/ifUZIti/1/edit
function findPlaces(boxes,searchIndex) {
var request = {
bounds: boxes[searchIndex],
query: 'gas station'
};
// alert(request.bounds);
service.textSearch(request, function (results, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert("Request["+searchIndex+"] failed: "+status);
return;
}
// alert(results.length);
document.getElementById('side_bar').innerHTML += "bounds["+searchIndex+"] returns "+results.length+" results<br>"
for (var i = 0, result; result = results[i]; i++) {
var marker = createMarker(result);
}
searchIndex++;
if (searchIndex < boxes.length)
findPlaces(boxes,searchIndex);
});
}
什么是textSearch
和nearbySearch
的区别,为什么当我尝试使用文本搜索代码搜索并在定义的框之外查找对象时?这里有什么问题?与nearbySearch
一切正常,但我不能将查询与附近搜索一起使用,所以我必须使用文本搜索,但textSearch
脚本搜索框外的对象?我该如何解决这个问题?
如果在高级渲染中放大看起来远离框外的位置,您将看到它们要么都在框内,要么就在框外。它并不像乍一看那么糟糕。请参阅我的代码版本以查看结果。
相关文章:
- 用程序搜索JQuery数据表中的文本
- 在html Select中添加搜索
- 谷歌位置服务附近搜索结果基于正确的地图中心的位置
- 如何使用谷歌地图中的纬度和经度搜索附近的位置
- 如何使用Google Places Javascript API搜索附近的位置(自动从浏览器获取坐标)
- 谷歌附近的地方搜索工作不正常
- 附近搜索的标记仅显示在最后一张地图上
- 放置 API 文本搜索与附近搜索
- 如何在 Google 地点 API 中使用附近的搜索功能查找地点详细信息
- 附近使用纬度和经度在谷歌地图中搜索
- Google Maps API javascript:附近搜索回调函数不调用
- 弹性搜索搜索过滤器等于问题
- 谷歌附近的搜索请求会间歇性地返回不同的值
- 将搜索附近的侧板添加到自定义谷歌地图
- 谷歌地图Api附近搜索-为什么Google.Maps.places.RankBy.DISTANCE返回的结果更少
- 获取谷歌附近搜索的JSON
- Google自定义搜索“搜索框”中的默认值
- 谷歌搜索附近的API没有给出观光的结果,为什么?
- 我如何在谷歌地图上更改附近的雷达搜索服务
- 使用附近搜索从Google地点API获取照片数组