1
我有這段JavaScript代碼動態谷歌地圖縮放的getBounds()未定義
var myOptions = {
zoom:9,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var latlongcollection = new Array();
// some more code to push latlng objects into latlongcollection
map.setCenter(latlongcollection[0]);
for(latlong in latlongcollection){
map.getBounds().extend(latlong);
}
map.fitBounds(map.getBounds());
但每次它給我的錯誤map.getBounds()是不確定的。中心設置,甚至。在我調用map.getBounds()之前設置縮放。使用新google.maps.LatLngBounds對象,而不是map.getBounds()的請幫忙