2021-05-27 19:53:22 +08:00
|
|
|
import { Scene, HeatmapLayer } from '@antv/l7';
|
2022-03-30 16:05:05 +08:00
|
|
|
import { GaodeMap, Mapbox, Map } from '@antv/l7-maps';
|
2021-04-26 15:13:16 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
export default class Amap2demo_heatmap extends React.Component {
|
|
|
|
// @ts-ignore
|
|
|
|
private scene: Scene;
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
this.scene.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async componentDidMount() {
|
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
2022-03-30 16:05:05 +08:00
|
|
|
map: new Map({
|
2022-02-24 16:17:38 +08:00
|
|
|
// pitch: 0,
|
|
|
|
// center: [127.5671666579043, 7.445038892195569],
|
|
|
|
// zoom: 2.632456779444394,
|
|
|
|
style: 'dark',
|
2021-04-26 15:13:16 +08:00
|
|
|
pitch: 0,
|
2022-02-24 16:17:38 +08:00
|
|
|
center: [120, 30],
|
|
|
|
zoom: 4,
|
2021-04-26 15:13:16 +08:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
this.scene = scene;
|
|
|
|
|
|
|
|
scene.on('loaded', () => {
|
2022-02-24 16:17:38 +08:00
|
|
|
// fetch(
|
|
|
|
// 'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json',
|
|
|
|
// )
|
|
|
|
// .then((res) => res.json())
|
|
|
|
// .then((data) => {
|
|
|
|
// const layer = new HeatmapLayer({})
|
|
|
|
// .source(data)
|
|
|
|
// .shape('heatmap')
|
|
|
|
// .size('mag', [0, 1.0]) // weight映射通道
|
|
|
|
// .style({
|
|
|
|
// intensity: 2,
|
|
|
|
// radius: 20,
|
|
|
|
// opacity: 1.0,
|
|
|
|
// rampColors: {
|
|
|
|
// colors: [
|
|
|
|
// '#FF4818',
|
|
|
|
// '#F7B74A',
|
|
|
|
// '#FFF598',
|
|
|
|
// '#91EABC',
|
|
|
|
// '#2EA9A1',
|
|
|
|
// '#206C7C',
|
|
|
|
// ].reverse(),
|
|
|
|
// positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0],
|
|
|
|
// },
|
|
|
|
// });
|
|
|
|
// scene.addLayer(layer);
|
|
|
|
// });
|
|
|
|
|
2021-04-26 15:13:16 +08:00
|
|
|
fetch(
|
2022-02-24 16:17:38 +08:00
|
|
|
'https://gw.alipayobjects.com/os/bmw-prod/95d5a2c3-f8fa-47f3-8664-ecb8459565ee.json',
|
2021-04-26 15:13:16 +08:00
|
|
|
)
|
2021-04-26 15:23:42 +08:00
|
|
|
.then((res) => res.json())
|
|
|
|
.then((data) => {
|
2021-04-26 15:13:16 +08:00
|
|
|
const layer = new HeatmapLayer({})
|
|
|
|
.source(data)
|
|
|
|
.shape('heatmap')
|
2022-02-24 16:17:38 +08:00
|
|
|
.size('weight', [0, 1.0]) // weight映射通道
|
2021-04-26 15:13:16 +08:00
|
|
|
.style({
|
2022-02-24 16:17:38 +08:00
|
|
|
intensity: 3,
|
|
|
|
radius: 24,
|
2021-04-26 15:13:16 +08:00
|
|
|
opacity: 1.0,
|
|
|
|
rampColors: {
|
2022-02-24 16:17:38 +08:00
|
|
|
colors: ['#030EAB', '#0F41EB', '#40D785', '#F1D41A', '#FE0257'],
|
|
|
|
positions: [0, 0.25, 0.5, 0.75, 1.0],
|
2021-04-26 15:23:42 +08:00
|
|
|
},
|
2021-04-26 15:13:16 +08:00
|
|
|
});
|
|
|
|
scene.addLayer(layer);
|
2021-04-26 15:23:42 +08:00
|
|
|
});
|
2021-04-26 15:13:16 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div
|
|
|
|
id="map"
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|