//去除底圖中的圖標,防止干擾
var styleJson =[
{
"featureType": "poilabel",
"elementType": "labels.icon",
"stylers": {
"visibility": "off"
}
},
{
"featureType": "subway",
"elementType": "labels.icon",
"stylers": {
"visibility": "off"
}
}
];
map.setMapStyle({styleJson:styleJson});
效果:
image.png
添加自定義標注
var label =new BMap.Label(name,{offset:new BMap.Size(38,5)});
if(tbdz==""){
tbdz="icon_c1.png";
}
var myIcon = new BMap.Icon("${base}/include/css/mapstyle/img/"+tbdz, new BMap.Size(36,36));
var marker = new BMap.Marker(point,{icon:myIcon});
//marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳動的動畫
label.setStyle({
color : color,
fontSize : "12px",
height : "20px",
//lineHeight : "20px",
fontFamily:"微軟雅黑",
backgroundColor:"rgba(255,255,255,0)",
border:"none"
});
label.setTitle(nameAll); //為label添加鼠標提示
map.addOverlay(marker);
marker.setLabel(label);
marker.addEventListener("touchstart", function () {
map.disableDragging(); //禁用地圖拖拽功能
});