最近在项目上用到高德地图, Maker需要标注, 但Label跟着旋转, 搞得标注难以阅读, 搞了好几个方案都不理想, 后来在API中看到了Maker的content参数, 终于被我找到了一个不错的解决办法, 不多说, 看代码:
Label跟着旋转:
var marker = new AMap.Marker({
map: map,
icon: 'icon.png',
position: [data[i].carX, data[i].carY],
angle: 45,
label: { 'content':'标注', 'direction':'bottom'},
});
把它修改为:
var marker = new AMap.Marker({
map: map,
position: [data[i].carX, data[i].carY],
content: '<div class="makerlabel"><img src="icon.png" style="transform:rotate(45deg)"></br><div style="border:solid 1px #00a0e9; background-color:#ffffff;position: absolute;">标注</div></div>',
});