當調用搜索服務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