marker = new BMap.Marker(pointList[i])
marker.setLabel(getNumberLabel(i));
function getNumberLabel(number) {
var offsetSize = new BMap.Size(0, 0);
var labelStyle = {
color: "#fff",
backgroundColor: "0.05",
border: "0"
};
//不同数字长度需要设置不同的样式。
switch((number + '').length) {
case 1:
labelStyle.fontSize = "14px";
offsetSize = new BMap.Size(4, 2);
break;
case 2:
labelStyle.fontSize = "12px";
offsetSize = new BMap.Size(2, 4);
break;
case 3:
labelStyle.fontSize = "10px";
offsetSize = new BMap.Size(-2, 4);
break;
default:
break;
}
var label = new BMap.Label(number, {
offset: offsetSize
});
label.setStyle(labelStyle);
return label;
}
}