首页地图
This commit is contained in:
parent
e78100eb41
commit
50891ca298
1
src/assets/localData/area-list.json
Normal file
1
src/assets/localData/area-list.json
Normal file
File diff suppressed because one or more lines are too long
@ -1,9 +1,11 @@
|
|||||||
import { Layout, Row, Col, Typography, Select } from 'antd';
|
import { Layout, Row, Col, Select } from 'antd';
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import styles from './Guide.less';
|
import styles from './Guide.less';
|
||||||
|
|
||||||
import { Scene, PointLayer } from '@antv/l7';
|
import { GaodeMap ,Scene } from '@antv/l7';
|
||||||
import { GaodeMap } from '@antv/l7-maps';
|
import { Choropleth } from '@antv/l7plot';
|
||||||
|
import areaList from '../../assets/localData/area-list.json'
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
name: string;
|
name: string;
|
||||||
@ -16,32 +18,73 @@ const Guide: React.FC<Props> = (props) => {
|
|||||||
const scene = new Scene({
|
const scene = new Scene({
|
||||||
id: 'map',
|
id: 'map',
|
||||||
map: new GaodeMap({
|
map: new GaodeMap({
|
||||||
pitch: 20,
|
// pitch: 20,
|
||||||
style: 'light',
|
style: 'light',
|
||||||
center: [ 120, 20 ],
|
center: [ 120, 20 ],
|
||||||
zoom: 3
|
zoom: 3
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
scene.on('loaded', () => {
|
scene.on('loaded', () => {
|
||||||
fetch(
|
const areadata = areaList;
|
||||||
'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json'
|
const data = areaList
|
||||||
)
|
// .filter(({ level, parent }) => level === 'city' && parent === 330000)
|
||||||
.then(res => res.json())
|
.map((item) => ({ ...item, value: Math.random() * 5000 }));
|
||||||
.then(data => {
|
|
||||||
const pointLayer = new PointLayer({})
|
const choropleth = new Choropleth({
|
||||||
.source(data)
|
source: {
|
||||||
.shape('simple')
|
data,
|
||||||
.size(15)
|
joinBy: {
|
||||||
.color('mag', mag => {
|
sourceField: 'adcode',
|
||||||
return mag > 4.5 ? '#5B8FF9' : '#5CCEA1';
|
geoField: 'adcode',
|
||||||
})
|
},
|
||||||
.active(true)
|
},
|
||||||
.style({
|
viewLevel: {
|
||||||
opacity: 0.6,
|
level: 'country',
|
||||||
strokeWidth: 3
|
adcode: 100000,
|
||||||
});
|
},
|
||||||
scene.addLayer(pointLayer);
|
autoFit: true,
|
||||||
});
|
color: {
|
||||||
|
field: 'value',
|
||||||
|
value: ['#B8E1FF', '#7DAAFF', '#3D76DD', '#0047A5', '#001D70'],
|
||||||
|
scale: { type: 'quantize' },
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
opacity: 1,
|
||||||
|
stroke: '#ccc',
|
||||||
|
lineWidth: 0.6,
|
||||||
|
lineOpacity: 1,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
visible: true,
|
||||||
|
field: 'name',
|
||||||
|
style: {
|
||||||
|
fill: '#000',
|
||||||
|
opacity: 0.8,
|
||||||
|
fontSize: 10,
|
||||||
|
stroke: '#fff',
|
||||||
|
strokeWidth: 1.5,
|
||||||
|
textAllowOverlap: false,
|
||||||
|
padding: [5, 5],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
state: {
|
||||||
|
active: { stroke: 'white', lineWidth: 1 },
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
items: ['name', 'adcode', 'value'],
|
||||||
|
},
|
||||||
|
zoom: {
|
||||||
|
position: 'bottomright',
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'bottomleft',
|
||||||
|
},
|
||||||
|
drill: {
|
||||||
|
steps: ['province', 'city', 'district'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
choropleth.addToScene(scene);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user