2012-03-28 63 views
2

從我今天開始,我一直在遇到谷歌地圖的一個問題,導致當我將一些IndoBox添加到地圖中時,導致地圖不居中。谷歌地圖V3 API地圖集中不正確

我有幾個資訊盒如下:

var labels = [ 
    new InfoBox({ 
     content: "Old Town (Stare Mesto)", 
     position: new google.maps.LatLng(50.088979, 14.414921), 
     boxStyle: { 
        border: "2px solid white", 
        textAlign: "center", 
        color: "white", 
        fontSize: "8pt", 
        fontWeight: "bold", 
        width: "200px", 
        height: "17px", 
        background: "black", 
        opacity: 0.5, 
        filter: "alpha(opacity=50)" 
     } 
    }), 
    new InfoBox({ 
     content: "New Town (Nove mesto)", 
     position: new google.maps.LatLng(50.084243, 14.424405), 
     boxStyle: { 
        border: "2px solid white", 
        textAlign: "center", 
        color: "white", 
        fontSize: "8pt", 
        fontWeight: "bold", 
        width: "200px", 
        height: "17px", 
        background: "black", 
        opacity: 0.5, 
        filter: "alpha(opacity=50)" 
     } 
    }) 
]; 

如果我將它們添加地圖

for (var i in labels) { 
    labels[i].open(map); 
} 

然後映射視移動到這些標籤。即使我調用map.setCenter(someLatLngObject)中心,也會在這些信息框中出現問題。

預期這種行爲?

回答

2

您是否嘗試過disableAutoPan選項?

new InfoBox({ 
     disableAutoPan: true, 
     content: "New Town (Nove mesto)", 
     position: new google.maps.LatLng(50.084243, 14.424405), 
+0

這似乎是工作,感謝您的幫助,我不知何故錯過了這個選項。 – Douglish 2012-03-28 16:44:26