2019-11-25 15:27:56 +08:00
|
|
|
import { LineLayer, Scene } from '@antv/l7';
|
2019-11-26 17:51:29 +08:00
|
|
|
import { Mapbox } from '@antv/l7-maps';
|
2019-11-21 13:44:32 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
export default class ArcLineDemo extends React.Component {
|
2019-11-25 15:27:56 +08:00
|
|
|
// @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(
|
2020-03-25 23:56:42 +08:00
|
|
|
'https://gw.alipayobjects.com/os/bmw-prod/4ededeaa-f290-46b7-a042-08210433e8f9.csv',
|
2019-11-21 13:44:32 +08:00
|
|
|
);
|
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
2019-11-26 17:51:29 +08:00
|
|
|
map: new Mapbox({
|
|
|
|
center: [116.2825, 39.9],
|
|
|
|
pitch: 0,
|
2019-12-25 00:01:14 +08:00
|
|
|
style: 'dark',
|
2019-11-26 17:51:29 +08:00
|
|
|
zoom: 2,
|
|
|
|
}),
|
2019-11-21 13:44:32 +08:00
|
|
|
});
|
2019-12-17 11:14:31 +08:00
|
|
|
this.scene = scene;
|
2019-11-25 15:27:56 +08:00
|
|
|
const lineLayer = new LineLayer({
|
2019-12-25 00:01:14 +08:00
|
|
|
blend: 'normal',
|
2019-11-25 15:27:56 +08:00
|
|
|
})
|
2019-11-21 13:44:32 +08:00
|
|
|
.source(await response.text(), {
|
|
|
|
parser: {
|
|
|
|
type: 'csv',
|
|
|
|
x: 'lng1',
|
|
|
|
y: 'lat1',
|
|
|
|
x1: 'lng2',
|
|
|
|
y1: 'lat2',
|
|
|
|
},
|
|
|
|
})
|
2020-03-25 23:56:42 +08:00
|
|
|
// .size(1)
|
|
|
|
.shape('arc')
|
2020-01-15 15:11:33 +08:00
|
|
|
.select({
|
|
|
|
color: 'red',
|
|
|
|
})
|
2020-01-18 23:16:56 +08:00
|
|
|
.active({
|
|
|
|
color: 'red',
|
|
|
|
})
|
2020-03-25 23:56:42 +08:00
|
|
|
// .color('rgb(13,64,140)')
|
2019-12-25 00:01:14 +08:00
|
|
|
.style({
|
2020-03-25 23:56:42 +08:00
|
|
|
opacity: 1,
|
2019-12-25 00:01:14 +08:00
|
|
|
});
|
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,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|