2
我試圖限制,像這樣從谷歌地圖API地理編碼器返回的地址限制:谷歌地圖API地理編碼器,通過邊界
var geocoder = new google.maps.Geocoder();
var auVicSwLatLon = new google.maps.LatLng(-39.234713, 140.962526);
var auVicNeLatLon = new google.maps.LatLng(-33.981125, 149.975296);
var auVicLatLonBounds = new google.maps.LatLngBounds(auVicSwLatLon, auVicNeLatLon);
geocoder.geocode(
{
address: searchStr,
region: 'AU',
// bounds: auVicLatLonBounds,
},
function(results, status) {
// ... do stuff here
}
);
使用限制區域的作品。然而,限制使用邊界不會 - 當我取消上面的邊界屬性的註釋時,我沒有得到任何結果。留下它的評論,我得到來自澳大利亞各地的結果。
有沒有什麼我在這裏做錯了?
謝謝!
附加信息:
相關文檔在這裏:
https://developers.google.com/maps/documentation/javascript/geocoding
這裏:
https://developers.google.com/maps/documentation/javascript/reference#Geocoder
注意,值我LatLngBounds
AR已使用e爲維多利亞州(維多利亞州)。這正是我想在這裏實現的。因此,如果你知道一種替代方法來完成這個,請回答這個問題!
當你使用'bounds' *而沒有'region'時會發生什麼?也許他們不能一起使用。 – 2012-08-08 08:44:37
也許這是一個暫時的錯誤。我正在嘗試,並沒有奏效,但現在我得到了結果。 – 2012-08-08 08:49:46
@AndrewLeach:是的,我已經嘗試過了,沒有地區的英鎊......不幸的是,無濟於事。 – bguiz 2012-08-08 10:45:03