在这里,我有一个演示,用于nearbySearch
搜索框内的对象(路由拳击手实用程序):
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
看到带有 textSearch 和查询搜索框外对象的代码... 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 代码搜索并在定义的框外查找对象时,和为什么textSearch
有什么区别?nearbySearch
这里有什么问题?一切正常,nearbySearch
但我不能在附近搜索中使用查询,所以我必须使用 textSearch 但textSearch
在框外使用脚本搜索对象?我该如何解决这个问题?