Google maps api 3 谷歌地图api zoom don';行不通

Google maps api 3 谷歌地图api zoom don';行不通,google-maps-api-3,Google Maps Api 3,我对缩放有问题。我试着用谷歌搜索,但似乎我被困在这上面了 如果我调整缩放参数中的设置,这将无效! 这是我代码中的错误,还是我遗漏了什么 如有任何帮助/提示,将不胜感激 var markers = [ <?php include("gmaps/hyttetomter.php"); ?> <?php include("gmaps/boligtomter.php"); ?> , ]; window.onload = function () {

我对缩放有问题。我试着用谷歌搜索,但似乎我被困在这上面了

如果我调整缩放参数中的设置,这将无效! 这是我代码中的错误,还是我遗漏了什么

如有任何帮助/提示,将不胜感激

var markers = [
    <?php include("gmaps/hyttetomter.php"); ?>
    <?php include("gmaps/boligtomter.php"); ?>
 ,    ];
window.onload = function () {

    var mapOptions = {
        panControl: true,
        streetViewControl: false,
        panControlOptions: {
            position: google.maps.ControlPosition.TOP_LEFT
        },
        mapTypeControlOptions: {
            style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
            position: google.maps.ControlPosition.TOP_RIGHT
        },
        center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
        zoom: 13,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var infoWindow = new google.maps.InfoWindow();

    var imageBounds = new google.maps.LatLngBounds(
        new google.maps.LatLng(58.608394, 7.940108),
        new google.maps.LatLng(58.996358, 8.781880)
    );

    var latlngbounds = new google.maps.LatLngBounds();
    var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
    var i = 0;

    var interval = setInterval(function () {
        var data = markers[i]
        var myLatlng = new google.maps.LatLng(data.lat, data.lng);
        var icon = "";
        switch (data.type) {
            case "Hyttefelt":
                icon = "red";
                break;
            case "Boligfelt":
                icon = "yellow";
                break;
            case "Hyttetomt":
                icon = "blue";
                break;
            case "Boligtomt":
                icon = "green";
                break;
        }
        icon = "http://maps.google.com/mapfiles/ms/icons/" + icon + ".png";
        var marker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            title: data.title,
            animation: google.maps.Animation.DROP,
            icon: new google.maps.MarkerImage(icon)
        });

        (function (marker, data) {
            google.maps.event.addListener(marker, "click", function (e) {
                window.location.href = data.description;
            });
        })(marker, data); 

        latlngbounds.extend(marker.position);
        i++;

        if (i == markers.length) {
            clearInterval(interval);
            map.setCenter(latlngbounds.getCenter());
            map.fitBounds(latlngbounds);
        }   
        historicalOverlay = new google.maps.GroundOverlay(
            'images/map/kart-amli.png',
            imageBounds
        );
        historicalOverlay.setMap(map);
    }, 80); 
}
var标记=[
,    ];
window.onload=函数(){
变量映射选项={
泛控制:对,
街景控制:错误,
全控选项:{
位置:google.maps.ControlPosition.TOP_左
},
mapTypeControlOptions:{
样式:google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
位置:google.maps.ControlPosition.TOP\u右
},
中心:新建google.maps.LatLng(标记[0].lat,标记[0].lng),
缩放:13,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
var infoWindow=new google.maps.infoWindow();
var imageBounds=new google.maps.LatLngBounds(
新的google.maps.LatLng(58.608394,7.940108),
新google.maps.LatLng(58.996358,8.781880)
);
var latlngbounds=new google.maps.latlngbounds();
var map=new google.maps.map(document.getElementById(“dvMap”)、mapOptions);
var i=0;
var interval=setInterval(函数(){
var数据=标记[i]
var mylatng=new google.maps.LatLng(data.lat,data.lng);
var图标=”;
开关(数据类型){
案例“Hytefelt”:
icon=“红色”;
打破
案例“Bolifelt”:
icon=“黄色”;
打破
“Hytetomt”案:
icon=“蓝色”;
打破
案例“Boligtomt”:
icon=“绿色”;
打破
}
图标=”http://maps.google.com/mapfiles/ms/icons/“+图标+”.png”;
var marker=new google.maps.marker({
职位:myLatlng,
地图:地图,
标题:data.title,
动画:google.maps.animation.DROP,
图标:新的google.maps.MarkerImage(图标)
});
(功能(标记、数据){
google.maps.event.addListener(标记“单击”,函数(e){
window.location.href=data.description;
});
})(标记、数据);
横向边界延伸(标记位置);
i++;
if(i==markers.length){
间隔时间;
map.setCenter(latlngbounds.getCenter());
地图边界(latlngbounds);
}   
historicalOverlay=新建google.maps.GroundOverlay(
“images/map/kart amli.png”,
图像边界
);
历史叠加。setMap(地图);
}, 80); 
}

这可能没有帮助,但这是代码,它对我有效,也许你必须像我一样把它全部放入一个变量中

var mapOptions = {
        zoom: 2,
        center: myLatlng
    } 

我找到了!
map.fitBounds(bounds)超过缩放功能


谢谢

不幸的是没有效果,参数被忽略(看起来)很抱歉,这对我的tho有效