2019-11-25 15:27:56 +08:00
|
|
|
import { PointLayer, 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';
|
2019-11-25 15:27:56 +08:00
|
|
|
// @ts-ignore
|
2019-11-21 13:44:32 +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-11-21 13:44:32 +08:00
|
|
|
private scene: Scene;
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
this.scene.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
public componentDidMount() {
|
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
2019-11-26 17:51:29 +08:00
|
|
|
map: new Mapbox({
|
|
|
|
center: [120.19382669582967, 30.258134],
|
|
|
|
pitch: 0,
|
|
|
|
style: 'mapbox://styles/mapbox/streets-v9',
|
|
|
|
zoom: 1,
|
|
|
|
}),
|
2019-11-21 13:44:32 +08:00
|
|
|
});
|
2019-11-25 15:27:56 +08:00
|
|
|
const pointLayer = new PointLayer({
|
|
|
|
enablePicking: true,
|
|
|
|
enableHighlight: true,
|
|
|
|
enableTAA: true,
|
|
|
|
onHover: (pickedFeature: any) => {
|
|
|
|
// tslint:disable-next-line:no-console
|
|
|
|
console.log('Scene4', pickedFeature.feature.name);
|
|
|
|
},
|
|
|
|
});
|
2019-11-21 13:44:32 +08:00
|
|
|
pointLayer
|
|
|
|
.source(data)
|
|
|
|
.color('red')
|
|
|
|
.shape('cylinder')
|
|
|
|
.size([15, 10]);
|
|
|
|
scene.addLayer(pointLayer);
|
|
|
|
scene.render();
|
|
|
|
this.scene = scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
id="map"
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|