代码
const map = new BMap.Map('map');
map.centerAndZoom(new BMap.Point(116.404, 39.915), 15);
var path = [
new BMap.Point(116.399, 39.91),
new BMap.Point(116.405, 39.92),
new BMap.Point(116.423493, 39.907445),
];
// 绘制线
var polyline = new BMap.Polyline(path, {
// 可以在初始化时通过 enableEditing 配置开启,默认false
enableEditing: true,
strokeWeight: 8,
strokeOpacity: 0.8,
});
map.addOverlay(polyline);
function enable() {
polyline.enableEditing();
}
function disable() {
polyline.disableEditing();
}
预览