//去除底图中的图标,防止干扰
var styleJson =[
{
"featureType": "poilabel",
"elementType": "labels.icon",
"stylers": {
"visibility": "off"
}
},
{
"featureType": "subway",
"elementType": "labels.icon",
"stylers": {
"visibility": "off"
}
}
];
map.setMapStyle({styleJson:styleJson});
效果:
添加自定义标注
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(); //禁用地图拖拽功能
});