小编use*_*178的帖子

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 …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps-api-3

8
推荐指数
1
解决办法
1161
查看次数

标签 统计

google-maps-api-3 ×1

javascript ×1