请勿使用标记旋转标签 - Google Maps API v3

时间:2017-11-02 19:27:26

标签: javascript google-maps google-maps-api-3

是否有一种简单的方法可以使标记随标记旋转移动?

以下是0°旋转的标记示例,标签正上方:

label at right position

但是当我旋转标记时,标签会随之旋转(移动),如下例所示:

label at wrong position

我想阻止它并使标签始终位于标记之上。这是一个创建标记的函数:

var path = 'M 4.2333332,0.26458333 C 3.6453105,0.26458333 3.6452221,1.5875001 3.6452221,1.5875001 V 3.4018596 L 0.26458331,5.3665975 V 6.2363118 L 3.6452221,5.4808025 V 6.6900309 L 2.4695001,7.6729167 V 8.2020834 L 3.8997703,7.9261312 C 3.9310853,8.0342939 4.0106398,8.1255601 4.1223122,8.1638429 4.3053607,8.2271499 4.5031497,8.1254389 4.5638959,7.9380168 4.5652259,7.9339868 4.5647152,7.9296768 4.5658959,7.9256158 L 5.9971665,8.2010511 V 7.6723999 L 4.8214444,6.6895142 V 5.479769 L 8.2020834,6.2363118 V 5.3665975 L 4.8214444,3.4018596 V 1.5875001 C 4.8214444,1.5875001 4.8213561,0.26458333 4.2333332,0.26458333 Z';
function createMarker(pos, hdg, icao) {
var icon = {
    path: path,
    fillColor: 'white',
    fillOpacity: 1,
    scale: 3,
    strokeColor: 'black',
    strokeWeight: 2,
    anchor: new google.maps.Point(3.97, 3.98),
    labelOrigin: new google.maps.Point(3.97, -3),
    rotation: hdg
};
var marker = new google.maps.Marker({
    position: pos,
    map: map,
    draggable: false,
    icon: icon,
    label: icao
});
return marker;
}

我知道当我设置labelOrigin以将标签放置在标记的中间时它不会移动,但在这种情况下,标签与标记相交,很难读取。

0 个答案:

没有答案