2021-06-28 21:02:52 +08:00
|
|
|
import { PointLayer, Scene } from '@antv/l7';
|
2022-03-30 16:05:05 +08:00
|
|
|
import { GaodeMap, GaodeMapV2, Mapbox } from '@antv/l7-maps';
|
2021-06-28 21:02:52 +08:00
|
|
|
import * as React from 'react';
|
|
|
|
export default class Amap2demo_styleMap 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 GaodeMapV2({
|
2021-06-28 21:02:52 +08:00
|
|
|
center: [112, 30.267069],
|
|
|
|
pitch: 0,
|
|
|
|
style: 'dark',
|
2021-06-28 21:08:21 +08:00
|
|
|
zoom: 6,
|
2021-06-28 21:02:52 +08:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
this.scene = scene;
|
|
|
|
scene.on('loaded', () => {
|
2021-07-02 11:07:09 +08:00
|
|
|
fetch(
|
|
|
|
'https://gw.alipayobjects.com/os/bmw-prod/450b2d95-006c-4bad-8269-15729269e142.json',
|
|
|
|
)
|
|
|
|
.then((res) => res.json())
|
|
|
|
.then((data) => {
|
2022-02-12 19:13:59 +08:00
|
|
|
let layer = new PointLayer({}) // blend: "additive"
|
2021-07-02 11:07:09 +08:00
|
|
|
.source(data, {
|
|
|
|
parser: {
|
|
|
|
type: 'json',
|
|
|
|
x: 'lng',
|
|
|
|
y: 'lat',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.shape('circle')
|
|
|
|
.color('color')
|
|
|
|
.size('value', (v) => 5 + 15 * v)
|
|
|
|
.style({
|
|
|
|
stroke: 'strokeColor',
|
|
|
|
// stroke: ['strokeColor', (d: any) => {
|
|
|
|
// return d
|
|
|
|
// }],
|
2021-06-28 21:02:52 +08:00
|
|
|
|
2021-07-02 11:07:09 +08:00
|
|
|
strokeWidth: 'strokeWidth',
|
|
|
|
// strokeWidth: ["strokeWidth", (d: any) => {
|
|
|
|
// return d * 2
|
|
|
|
// }],
|
|
|
|
strokeOpacity: [
|
|
|
|
'strokeOpacity',
|
|
|
|
(d: any) => {
|
|
|
|
return d * 2;
|
|
|
|
},
|
|
|
|
],
|
2021-06-28 21:02:52 +08:00
|
|
|
|
2021-07-02 11:07:09 +08:00
|
|
|
opacity: 'opacity',
|
|
|
|
})
|
|
|
|
.active(true);
|
|
|
|
scene.addLayer(layer);
|
|
|
|
});
|
2021-06-28 21:02:52 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div
|
|
|
|
id="map"
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|