mirror of https://gitee.com/antv-l7/antv-l7
79 lines
1.3 KiB
TypeScript
79 lines
1.3 KiB
TypeScript
import {
|
|
LineLayer,
|
|
Scene,
|
|
MaskLayer,
|
|
PolygonLayer,
|
|
PointLayer,
|
|
} from '@antv/l7';
|
|
import { GaodeMap } from '@antv/l7-maps';
|
|
import * as React from 'react';
|
|
|
|
import CustomPoint from './CustomPointLayer';
|
|
|
|
export default class Demo extends React.Component {
|
|
private scene: Scene;
|
|
|
|
public componentWillUnmount() {
|
|
this.scene.destroy();
|
|
}
|
|
|
|
public async componentDidMount() {
|
|
const scene = new Scene({
|
|
id: 'map',
|
|
stencil: true,
|
|
map: new GaodeMap({
|
|
center: [120, 30],
|
|
pitch: 0,
|
|
zoom: 15,
|
|
style: 'dark',
|
|
}),
|
|
});
|
|
this.scene = scene;
|
|
let layer = new CustomPoint()
|
|
// @ts-ignore
|
|
.source(
|
|
[
|
|
{
|
|
lng: 120,
|
|
lat: 30,
|
|
},
|
|
],
|
|
{
|
|
parser: {
|
|
type: 'json',
|
|
x: 'lng',
|
|
y: 'lat',
|
|
},
|
|
},
|
|
)
|
|
.shape('circle')
|
|
.color('#ff0')
|
|
.size(30)
|
|
.style({
|
|
opacity: 0.3,
|
|
})
|
|
.active(true);
|
|
|
|
scene.on('loaded', () => {
|
|
scene.addLayer(layer);
|
|
});
|
|
}
|
|
|
|
public render() {
|
|
return (
|
|
<>
|
|
<div
|
|
id="map"
|
|
style={{
|
|
position: 'absolute',
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
}}
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
}
|