2019-11-25 15:27:56 +08:00
|
|
|
import { PointLayer, Scene } from '@antv/l7';
|
2019-11-28 00:26:09 +08:00
|
|
|
import { GaodeMap, Mapbox } from '@antv/l7-maps';
|
2019-10-29 17:33:37 +08:00
|
|
|
import * as React from 'react';
|
2019-11-25 15:27:56 +08:00
|
|
|
// @ts-ignore
|
2019-10-29 17:33:37 +08:00
|
|
|
import data from '../data/data.json';
|
|
|
|
export default class Point3D extends React.Component {
|
2019-11-25 15:27:56 +08:00
|
|
|
// @ts-ignore
|
2019-10-29 17:33:37 +08:00
|
|
|
private scene: Scene;
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
this.scene.destroy();
|
|
|
|
}
|
|
|
|
|
2019-11-26 20:37:39 +08:00
|
|
|
public async componentDidMount() {
|
|
|
|
const response = await fetch(
|
|
|
|
'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json',
|
|
|
|
);
|
|
|
|
const pointsData = await response.json();
|
2019-12-07 01:43:18 +08:00
|
|
|
|
2019-10-29 17:33:37 +08:00
|
|
|
const scene = new Scene({
|
2020-02-11 16:35:18 +08:00
|
|
|
id: document.getElementById('map') as HTMLDivElement,
|
2020-01-07 21:15:23 +08:00
|
|
|
map: new Mapbox({
|
2019-11-26 17:51:29 +08:00
|
|
|
center: [120.19382669582967, 30.258134],
|
|
|
|
pitch: 0,
|
2019-12-07 01:43:18 +08:00
|
|
|
style: 'dark',
|
2020-02-04 22:37:11 +08:00
|
|
|
zoom: 0,
|
2019-11-26 17:51:29 +08:00
|
|
|
}),
|
2019-10-29 17:33:37 +08:00
|
|
|
});
|
2019-12-26 11:42:09 +08:00
|
|
|
// scene.on('loaded', () => {
|
|
|
|
const pointLayer = new PointLayer({})
|
|
|
|
.source(pointsData, {
|
2020-01-08 22:42:43 +08:00
|
|
|
cluster: false,
|
2019-12-26 11:42:09 +08:00
|
|
|
})
|
|
|
|
.shape('circle')
|
2020-01-08 22:42:43 +08:00
|
|
|
// .scale('point_count', {
|
|
|
|
// type: 'quantile',
|
|
|
|
// })
|
2020-01-16 18:22:38 +08:00
|
|
|
.size('mag', [5, 10, 15, 20, 25])
|
2019-12-26 22:36:50 +08:00
|
|
|
.animate(false)
|
2020-01-07 21:15:23 +08:00
|
|
|
.active(true)
|
2019-12-26 11:42:09 +08:00
|
|
|
.color('yellow')
|
|
|
|
.style({
|
2020-01-16 18:22:38 +08:00
|
|
|
opacity: 0.5,
|
2019-12-26 11:42:09 +08:00
|
|
|
strokeWidth: 1,
|
2019-12-18 00:33:25 +08:00
|
|
|
});
|
2019-12-26 11:42:09 +08:00
|
|
|
scene.addLayer(pointLayer);
|
2020-01-16 18:22:38 +08:00
|
|
|
scene.on('loaded', () => {
|
|
|
|
const newData = {
|
|
|
|
type: 'FeatureCollection',
|
|
|
|
features: pointsData.features.slice(0, 100),
|
|
|
|
};
|
|
|
|
pointLayer.setData(newData);
|
|
|
|
});
|
2019-12-26 11:42:09 +08:00
|
|
|
this.scene = scene;
|
|
|
|
// });
|
2019-10-29 17:33:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
id="map"
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|