我正在使用Google Maps V3 API的實用工具庫中的InfoBox類來製作與點相關聯的標籤。InfoBox標籤不會按預期偏移
現在,我的目標是有標籤整齊地繞流點,但你可以看到,這是不會發生:
你可以從信息框規格,pixelOffset,用於看需要一個Size對象(https://developers.google.com/maps/documentation/javascript/reference#Size)。文檔沒有說明接受哪些值的很多內容。 (I,當然希望負值。)
首先,我有一個數組與偏移值:
var arr = [
{x: -25, y: -25},
{x: -25, y: 0},
{x: -25, y: 25},
{x: 0, y: -25},
{x: 0, y: 0},
{x: 0, y: 25},
{x: 25, y: -25},
{x: 25, y: 0},
{x: 25, y: 25}
];
然後,位置:
var lat = 58.9030277;
var lng = 5.7114827999999990;
最後,環路產生標記和偏移量:
for (i = 0; i < arr.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(lat, lng)
});
var myOptions = {
content: '#' + (i + 1),
disableAutoPan: true,
pixelOffset: new google.maps.Size(arr[i].x, arr[i].y),
position: new google.maps.LatLng(lat, lng)
};
ib = new InfoBox(myOptions);
}
有沒有人瞭解這種行爲?有沒有更好的方法來獲得這個結果?
感謝一堆,工作。 – Hermiene