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

57 lines
1.2 KiB
TypeScript
Raw Normal View History

import { PointLayer, Scene } from '@antv/l7';
import { Mapbox } from '@antv/l7-maps';
2019-11-21 13:44:32 +08:00
import * as React from 'react';
// @ts-ignore
2019-11-21 13:44:32 +08:00
import data from '../data/data.json';
export default class Point3D extends React.Component {
// @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',
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
});
const pointLayer = new PointLayer();
2019-11-21 13:44:32 +08:00
pointLayer
2019-12-07 01:43:18 +08:00
.source(data, {
cluster: true,
})
2019-11-21 13:44:32 +08:00
.color('red')
.shape('cylinder')
.active({ color: 'blue' })
2019-11-21 13:44:32 +08:00
.size([15, 10]);
scene.addLayer(pointLayer);
setTimeout(() => {
pointLayer.size([20, 100]);
scene.render();
console.log('update size');
}, 2000);
2019-11-21 13:44:32 +08:00
scene.render();
this.scene = scene;
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
);
}
}