antv-l7/stories/Layers/components/Arc2DLine.tsx

67 lines
1.3 KiB
TypeScript
Raw Normal View History

import { LineLayer, Scene } from '@antv/l7';
import { Mapbox, GaodeMap } from '@antv/l7-maps';
2019-11-21 13:44:32 +08:00
import * as React from 'react';
export default class Arc2DLineDemo extends React.Component {
// @ts-ignore
2019-11-21 13:44:32 +08:00
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const response = await fetch(
'https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt',
);
const scene = new Scene({
id: 'map',
map: new GaodeMap({
center: [116.2825, 39.9],
pitch: 0,
style: 'dark',
zoom: 2,
}),
2019-11-21 13:44:32 +08:00
});
const lineLayer = new LineLayer()
2019-11-21 13:44:32 +08:00
.source(await response.text(), {
parser: {
type: 'csv',
x: 'lng1',
y: 'lat1',
x1: 'lng2',
y1: 'lat2',
},
})
.size(1.2)
.shape('greatcircle')
.color('rgb(13,64,140)')
.animate({
interval: 0.5,
duration: 2,
trailLength: 0.4,
})
.style({
opacity: 0.6,
});
2019-11-21 13:44:32 +08:00
scene.addLayer(lineLayer);
scene.render();
this.scene = scene;
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
);
}
}