antv-l7/stories/Map/components/bugfix.tsx

86 lines
1.6 KiB
TypeScript

// @ts-nocheck
import React from 'react';
import {
Scene,
GaodeMap,
GaodeMapV2,
Mapbox,
Map,
PointLayer,
Marker,
MarkerLayer,
Popup,
HeatmapLayer,
} from '@antv/l7';
export default class Amap2demo extends React.Component {
// @ts-ignore
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
pitch: 0,
style: 'blank',
// center: [115, 30],
center: [120, 30],
zoom: 0,
// layers: [new window.AMap.TileLayer.Satellite()]
}),
});
this.scene = scene;
scene.on('loaded', () => {
const layer = new HeatmapLayer({})
.source([{ lng: 120, lat: 30, mag: 1 }], {
parser: { type: 'json', x: 'lng', y: 'lat' },
})
.shape('heatmap')
.size('mag', [0, 1.0]) // weight映射通道
.style({
intensity: 2,
radius: 20,
opacity: 1.0,
rampColors: {
colors: [
'#FF4818',
'#F7B74A',
'#FFF598',
'#F27DEB',
'#8C1EB2',
'#421EB2',
].reverse(),
positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0],
},
});
this.scene.addLayer(layer);
});
}
public render() {
return (
<>
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
></div>
</>
);
}
}