antv-l7/stories/Draw/Components/DrawRect.tsx

46 lines
932 B
TypeScript
Raw Normal View History

2020-03-20 11:13:58 +08:00
import { LineLayer, PointLayer, PolygonLayer, Popup, Scene } from '@antv/l7';
2020-03-24 22:24:26 +08:00
import { DrawRect } from '@antv/l7-draw';
2020-03-20 11:13:58 +08:00
import { GaodeMap, Mapbox } from '@antv/l7-maps';
2020-03-24 22:24:26 +08:00
import * as React from 'react';
export default class Circle extends React.Component {
2020-03-20 11:13:58 +08:00
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const scene = new Scene({
id: 'map',
map: new Mapbox({
pitch: 0,
2020-03-24 22:24:26 +08:00
style: 'light',
center: [113.775374, 28.31067],
zoom: 12,
2020-03-20 11:13:58 +08:00
}),
});
this.scene = scene;
scene.on('loaded', () => {
2020-03-24 22:24:26 +08:00
const drawRect = new DrawRect(scene);
drawRect.enable();
2020-03-20 11:13:58 +08:00
});
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
);
}
}