2020-04-26 16:45:30 +08:00
|
|
|
import { Scene } from '@antv/l7';
|
|
|
|
import { WorldLayer } from '@antv/l7-district';
|
|
|
|
import { GaodeMap, Mapbox } from '@antv/l7-maps';
|
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
export default class Country extends React.Component {
|
|
|
|
// @ts-ignore
|
|
|
|
private scene: Scene;
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
|
|
|
this.scene.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async componentDidMount() {
|
|
|
|
const scene = new Scene({
|
|
|
|
id: 'map',
|
|
|
|
map: new Mapbox({
|
|
|
|
center: [116.2825, 39.9],
|
|
|
|
pitch: 0,
|
|
|
|
style: 'blank',
|
|
|
|
zoom: 0,
|
|
|
|
minZoom: 0,
|
|
|
|
maxZoom: 10,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
scene.on('loaded', () => {
|
|
|
|
const Layer = new WorldLayer(scene, {
|
|
|
|
data: [],
|
2020-05-15 21:07:04 +08:00
|
|
|
bubble: {
|
|
|
|
enable: true,
|
|
|
|
color: {
|
|
|
|
field: 'NAME_CHN',
|
|
|
|
values: [
|
|
|
|
'#feedde',
|
|
|
|
'#fdd0a2',
|
|
|
|
'#fdae6b',
|
|
|
|
'#fd8d3c',
|
|
|
|
'#e6550d',
|
|
|
|
'#a63603',
|
|
|
|
],
|
|
|
|
},
|
2020-04-26 16:45:30 +08:00
|
|
|
},
|
|
|
|
stroke: '#ccc',
|
|
|
|
label: {
|
2020-05-12 17:59:42 +08:00
|
|
|
enable: true,
|
2020-04-26 16:45:30 +08:00
|
|
|
textAllowOverlap: false,
|
2020-05-27 00:21:09 +08:00
|
|
|
field: 'NAME_CHN',
|
2020-04-26 16:45:30 +08:00
|
|
|
},
|
2020-04-29 12:03:06 +08:00
|
|
|
popup: {
|
|
|
|
enable: false,
|
|
|
|
Html: (props) => {
|
2020-05-27 00:21:09 +08:00
|
|
|
return `<span>${props.NAME_CHN}</span>`;
|
2020-04-29 12:03:06 +08:00
|
|
|
},
|
|
|
|
},
|
2020-04-26 16:45:30 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
this.scene = scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
id="map"
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|