2021-05-27 19:53:22 +08:00
|
|
|
import { CityBuildingLayer, Scene } from '@antv/l7';
|
2021-12-17 10:54:06 +08:00
|
|
|
import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
|
2021-04-26 15:13:16 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
export default class Amap2demo_citybuilding extends React.Component {
|
|
|
|
// @ts-ignore
|
|
|
|
private scene: Scene;
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
this.scene.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async componentDidMount() {
|
|
|
|
const response = await fetch(
|
|
|
|
'https://gw.alipayobjects.com/os/rmsportal/vmvAxgsEwbpoSWbSYvix.json',
|
|
|
|
);
|
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
2021-05-27 19:53:22 +08:00
|
|
|
map: new GaodeMap({
|
2021-04-26 15:13:16 +08:00
|
|
|
style: 'dark',
|
|
|
|
center: [121.507674, 31.223043],
|
|
|
|
pitch: 65.59312320916906,
|
2021-04-26 15:23:42 +08:00
|
|
|
zoom: 15.4,
|
2021-05-27 19:53:22 +08:00
|
|
|
viewMode: '3D',
|
2021-04-26 15:13:16 +08:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
const pointLayer = new CityBuildingLayer();
|
|
|
|
pointLayer
|
|
|
|
.source(await response.json())
|
|
|
|
.size('floor', [0, 500])
|
|
|
|
.color('rgba(242,246,250,1.0)')
|
|
|
|
.animate({
|
2021-12-17 10:54:06 +08:00
|
|
|
enable: true,
|
2021-04-26 15:13:16 +08:00
|
|
|
})
|
2021-12-21 13:57:48 +08:00
|
|
|
.active({
|
|
|
|
color: '#0ff',
|
|
|
|
mix: 0.5,
|
|
|
|
})
|
2021-04-26 15:13:16 +08:00
|
|
|
.style({
|
|
|
|
opacity: 0.7,
|
|
|
|
baseColor: 'rgb(16,16,16)',
|
|
|
|
windowColor: 'rgb(30,60,89)',
|
|
|
|
brightColor: 'rgb(255,176,38)',
|
2021-12-21 13:57:48 +08:00
|
|
|
sweep: {
|
|
|
|
enable: true,
|
|
|
|
sweepRadius: 4,
|
|
|
|
sweepColor: 'rgb(0, 100, 100)',
|
|
|
|
sweepSpeed: 0.5,
|
|
|
|
},
|
2021-04-26 15:13:16 +08:00
|
|
|
});
|
|
|
|
scene.addLayer(pointLayer);
|
|
|
|
|
|
|
|
this.scene = scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div
|
|
|
|
id="map"
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|