antv-l7/packages/site/examples/earth/arc3d/demo/flyline.js

78 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-10-13 16:51:20 +08:00
import { Scene, EarthLayer, LineLayer } from '@antv/l7';
import { Earth } from '@antv/l7-maps';
const scene = new Scene({
id: 'map',
map: new Earth({})
});
// TODO: 地球模式下背景色默认为 #000 通过 setBgColor 方法我们可以设置可视化层的背景色
scene.setBgColor('#333');
const earthlayer = new EarthLayer()
.source(
'https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*3-3NSpqRqUoAAAAAAAAAAAAAARQnAQ',
{
parser: {
type: 'image'
2021-10-13 16:51:20 +08:00
}
}
)
.color('#2E8AE6')
.shape('fill')
.style({
globelOtions: {
ambientRatio: 0.6, // 环境光
diffuseRatio: 0.4, // 漫反射
specularRatio: 0.1 // 高光反射
}
})
.animate(true);
const atomLayer = new EarthLayer()
.color('#2E8AE6')
.shape('atomSphere')
.style({
opacity: 1
});
const bloomLayer = new EarthLayer().color('#fff').shape('bloomSphere')
.style({
opacity: 0.7
});
scene.on('loaded', () => {
scene.addLayer(earthlayer);
scene.addLayer(atomLayer);
scene.addLayer(bloomLayer);
fetch('https://gw.alipayobjects.com/os/bmw-prod/20a69b46-3d6d-4ab5-b8b5-150b6aa52c88.json')
.then(res => res.json())
.then(flydata => {
const flyLine = new LineLayer({ blend: 'normal' })
.source(flydata, {
parser: {
type: 'json',
coordinates: 'coord'
}
})
.color('#b97feb')
.shape('arc3d')
.size(0.5)
.active(true)
.animate({
interval: 2,
trailLength: 2,
duration: 1
})
.style({
opacity: 1,
segmentNumber: 60,
globalArcHeight: 20
});
scene.addLayer(flyLine);
});
2021-10-14 10:56:08 +08:00
2021-10-13 16:51:20 +08:00
earthlayer.setEarthTime(4.0);
});