我有一个非常奇怪的错误,当我尝试调整地图大小以适应放置在其上的标记时,导致浏览器冻结。map.fitBounds(bounds)导致浏览器冻结
参考我的大小调整代码:
function sizeMap() {
// create a new bounds object to define the new boundry
var bounds = new google.maps.LatLngBounds();
// loop through each the string latlang values held in the latlng
// aray
for (var i = 0; i <latlngArray.length ; i++) {
// create a new LatLng object based on the string value
var tempLatLng = new google.maps.LatLng(latlngArray[i]);
// extend the latlng bounds based on the new location
bounds.extend(tempLatLng);
}
// map.fitBounds(bounds); <== everything seems to work fine until this line is uncommented
}
问题是我不能正确地调试它使用Firebug,因为冻结到了! 任何人对这个问题可能有什么想法?
在此先感谢。
更新:
在回答puckheads质疑下面的代码显示了经纬度阵列填充入手:
function geocodeAddress (address) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
loadMarker(results[0].geometry.location,"Info here",address);
latlngArray.push(results[0].geometry.location); <== latlngs are first added here they are as a result of a call to the google geocode service with a standard string address.
} else {
alert("Geocode was not successful for the following reason: " +" "+ status);
}
});
}
您是否解决了这个问题? - 如果是的话,你应该接受或写出你自己的正确答案! – levi 2014-07-08 15:43:03
您是否尝试过使用Chrome和JavaScript控制台? – MrUpsidown 2015-04-21 11:37:00