mirror of https://gitee.com/antv-l7/antv-l7
73 lines
1.6 KiB
TypeScript
73 lines
1.6 KiB
TypeScript
import { LineLayer, Scene } from '@antv/l7';
|
|
import { GaodeMap } from '@antv/l7-maps';
|
|
import * as React from 'react';
|
|
|
|
export default class Amap2demo_winds extends React.Component {
|
|
// @ts-ignore
|
|
private scene: Scene;
|
|
|
|
public componentWillUnmount() {
|
|
this.scene.destroy();
|
|
}
|
|
|
|
public async componentDidMount() {
|
|
const scene = new Scene({
|
|
id: 'map',
|
|
map: new GaodeMap({
|
|
pitch: 0,
|
|
style: 'light',
|
|
center: [-74.006, 40.7128],
|
|
zoom: 2,
|
|
viewMode: '3D',
|
|
}),
|
|
});
|
|
this.scene = scene;
|
|
|
|
scene.on('loaded', () => {
|
|
fetch(
|
|
'https://gw.alipayobjects.com/os/bmw-prod/7455fead-1dc0-458d-b91a-fb4cf99e701e.txt',
|
|
)
|
|
.then((res) => res.text())
|
|
.then((data) => {
|
|
const layer = new LineLayer({ blend: 'normal' })
|
|
.source(data, {
|
|
parser: {
|
|
type: 'csv',
|
|
x: 'lng1',
|
|
y: 'lat1',
|
|
x1: 'lng2',
|
|
y1: 'lat2',
|
|
},
|
|
})
|
|
.size(1)
|
|
.shape('arc')
|
|
.color('#6495ED')
|
|
.animate({
|
|
duration: 4,
|
|
interval: 0.2,
|
|
trailLength: 0.6,
|
|
});
|
|
// .forward(false)
|
|
scene.addLayer(layer);
|
|
});
|
|
});
|
|
}
|
|
|
|
public render() {
|
|
return (
|
|
<>
|
|
<div
|
|
id="map"
|
|
style={{
|
|
position: 'absolute',
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
}}
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
}
|