2020-03-26 11:38:48 +08:00
|
|
|
import { HeatmapLayer, Scene } from '@antv/l7';
|
2020-03-26 20:15:16 +08:00
|
|
|
import { Mapbox, GaodeMap } from '@antv/l7-maps';
|
2020-03-26 11:38:48 +08:00
|
|
|
// @ts-ignore
|
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
export default class HeatMapLayerDemo 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/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json',
|
|
|
|
);
|
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
2020-03-26 16:59:19 +08:00
|
|
|
map: new GaodeMap({
|
2020-03-26 11:38:48 +08:00
|
|
|
style: 'dark',
|
2020-03-26 14:58:28 +08:00
|
|
|
pitch: 58.5,
|
|
|
|
center: [111.8759, 30.6942],
|
|
|
|
rotation: 0.519,
|
2020-03-28 11:19:57 +08:00
|
|
|
zoom: 14,
|
2020-03-26 11:38:48 +08:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
scene.on('loaded', () => {
|
2020-03-26 14:58:28 +08:00
|
|
|
fetch(
|
|
|
|
'https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json',
|
|
|
|
)
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((data) => {
|
|
|
|
const layer = new HeatmapLayer({})
|
|
|
|
.source(data)
|
|
|
|
.size('capacity', [0, 1])
|
|
|
|
.shape('heatmap3D')
|
|
|
|
// weight映射通道
|
|
|
|
.style({
|
|
|
|
intensity: 10,
|
|
|
|
radius: 5,
|
|
|
|
opacity: 1.0,
|
|
|
|
rampColors: {
|
|
|
|
colors: [
|
|
|
|
'#2E8AE6',
|
|
|
|
'#69D1AB',
|
|
|
|
'#DAF291',
|
|
|
|
'#FFD591',
|
|
|
|
'#FF7A45',
|
|
|
|
'#CF1D49',
|
|
|
|
],
|
|
|
|
positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0],
|
2020-03-26 16:04:39 +08:00
|
|
|
},
|
2020-03-26 14:58:28 +08:00
|
|
|
});
|
|
|
|
scene.addLayer(layer);
|
|
|
|
});
|
2020-03-26 11:38:48 +08:00
|
|
|
});
|
2020-03-26 14:58:28 +08:00
|
|
|
|
2020-03-26 11:38:48 +08:00
|
|
|
this.scene = scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
id="map"
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|