代码
const map = new BMap.Map('map');
map.centerAndZoom(new BMap.Point(116.475425, 39.903386), 13);
var pathData = [
[116.452492, 39.926156],
[116.456818, 39.92608],
[116.456977, 39.914121],
[116.468911, 39.91396],
[116.469301, 39.913961],
[116.479974, 39.91396],
[116.493094, 39.914035],
[116.496187, 39.910533],
[116.496166, 39.890058],
[116.496147, 39.888438],
[116.495959, 39.888165],
[116.493289, 39.877937],
];
var path = pathData.map((item) => new BMap.Point(...item));
var polyline = new BMap.Polyline(path, {
strokeColor: '#28a745',
strokeWeight: 8,
strokeOpacity: 1,
strokeTexture: {
url: 'http://mapopen-pub-jsapigl.bj.bcebos.com/svgmodel/Icon_road_green_arrow.png',
width: 16,
height: 64,
},
});
map.addOverlay(polyline);
JSAPI 4.0支持 strokeTexture 设置纹理贴图
预览