当调用搜索服务API谷歌地图Javascript API第3:搜索请求
var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316);
var request = { location: pyrmont, radius: '500', types: ['store'] };
service = new google.maps.places.PlacesService(map);
service.search(request, callback);
- 是有必要给搜索区域的位置/半径?
- 那么如果我想搜索一个位于全球不在指定区域的位置,如google在http://maps.google.com/处怎么样。
--- UPDATE ---
这是我更新的代码为@Trott建议,但我在我的回调函数获取状态= “ZERO_RESULTS”。
var keyword='search placename';
var request = { name : keyword,
bounds : new google.maps.LatLngBounds(
google.maps.LatLng(-89.999999,-179.999999),
google.maps.LatLng(89.999999,179.999999)
)};
service = new google.maps.places.PlacesService(map);
service.search(request, callback);
function callback(results, status)
{
console.log("status="+status);
if (status == google.maps.places.PlacesServiceStatus.OK)
{
for (var i = 0; i < results.length; i++)
console.log(results[i]);
}
}
我做错了什么?
在走的权利,但确实很快:我强烈怀疑为“搜索地名”一谷歌搜索的地方会拿出空的,尤其是考虑如何疏Google地方资讯数据库目前正在使用。尝试搜索“博物馆”,看看是否得到任何结果。 – Trott 2011-06-23 00:52:57