代码
const map = new BMap.Map('map');
map.centerAndZoom(new BMap.Point(116.404, 39.915), 6);
map.enableScrollWheelZoom(true);
map.setTilt(45);
map.setMapStyle({
styleJson: darkStyle,
merge: true,
});
const start = [116.404, 39.915];
const destinations = [
[126.642, 45.756],
[121.472, 31.231],
[113.264, 23.129],
[104.066, 30.572],
[91.132, 29.66],
[87.617, 43.792],
[108.948, 34.263],
[102.712, 25.04],
];
const arcData = {
type: 'FeatureCollection',
features: destinations.map(function (destination) {
return {
type: 'Feature',
properties: {
name: 'to ' + destination.join(','),
},
geometry: {
type: 'LineString',
coordinates: [start, destination],
},
};
}),
};
const flyLineLayer = new BMap.FlyLineLayer({
mode: 'arc',
strokeColor: 'rgba(120, 160, 255, 0.9)',
strokeWeight: 4,
blend: 'lighter',
});
map.addLayer(flyLineLayer);
flyLineLayer.setData(arcData);
通过 new BMap.FlyLineLayer 创建弧线飞线图层,展示从北京发往多个方向的飞线效果。
预览