2012-03-28 16 views
2

今日から地図にインドボックスをいくつか追加すると、マップの中心にならないというGoogleマップの問題が発生しています。Google Maps V3 APIマップが正しく中央にない

次のように私はいくつかInfoBoxesを持っている:

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