我剛開始使用Google Places API(http://code.google.com/apis/maps/documentation/javascript/places.html),但我無法看到獲得傳遞範圍的語法,而不是latLng對象和半徑。將界限傳遞到Google地點API
在它說的API文檔:
This method takes a request with the following fields: Either of: bounds, which must be a google.maps.LatLngBounds object defining the rectangle in which to search; or a location and radius; the former takes a google.maps.LatLng object, and the radius takes a simple integer, representing the circle's radius in meters.
我的代碼如下所示:
var bnds = map.getBounds();
console.log(bnds); // this returns a valid bounds object!
var req = {
bounds: bnds
};
var service = new google.maps.places.PlacesService(map);
service.search(req, callback);
當我運行頁面,我從谷歌服務出現錯誤Uncaught Error: Property bounds not specified
。如果我將req對象更改爲
var req = {
location: latlngobject,
radius: '500'
}
它正常工作。任何關於傳遞邊界對象而不是lat/lng/radius的正確語法的想法?
也應該補充說,當我提交 'var req時,我得到同樣的錯誤。 。 .location:bnds' – julio
我得到「物業位置沒有指定。」當只通過界限時。你有沒有解決這個問題?似乎是API中的一個錯誤。 – Gady