2020-04-26 16:45:30 +08:00
|
|
|
import { Scene } from '@antv/l7';
|
|
|
|
import { CountryLayer } 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: 3,
|
|
|
|
minZoom: 3,
|
2020-06-08 11:29:18 +08:00
|
|
|
maxZoom: 10,
|
2020-04-26 16:45:30 +08:00
|
|
|
}),
|
|
|
|
});
|
|
|
|
scene.on('loaded', () => {
|
|
|
|
const Layer = new CountryLayer(scene, {
|
|
|
|
data: [],
|
2020-05-29 21:11:05 +08:00
|
|
|
geoDataLevel: 2,
|
2020-04-26 16:45:30 +08:00
|
|
|
depth: 2,
|
2020-07-02 19:35:50 +08:00
|
|
|
showBorder: false,
|
2020-05-29 21:11:05 +08:00
|
|
|
provinceStroke: '#783D2D',
|
|
|
|
cityStroke: '#EBCCB4',
|
2020-04-26 16:45:30 +08:00
|
|
|
coastlineWidth: 0.5,
|
|
|
|
nationalWidth: 0.5,
|
|
|
|
fill: {
|
2020-05-15 21:07:04 +08:00
|
|
|
color: {
|
|
|
|
field: 'NAME_CHN',
|
2020-06-08 11:29:18 +08:00
|
|
|
values: ['#D92568', '#E3507E', '#FC7AAB', '#F1D3E5', '#F2EEFF'],
|
2020-05-15 21:07:04 +08:00
|
|
|
},
|
2020-04-26 16:45:30 +08:00
|
|
|
},
|
2020-04-29 12:03:06 +08:00
|
|
|
popup: {
|
|
|
|
enable: true,
|
2020-05-27 16:28:07 +08:00
|
|
|
Html: (props: any) => {
|
2020-04-29 12:03:06 +08:00
|
|
|
return `<span>${props.NAME_CHN}</span>`;
|
|
|
|
},
|
|
|
|
},
|
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,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|