mirror of https://gitee.com/antv-l7/antv-l7
55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
docs: scale demo & IE 兼容 (#1304)
* docs: 增加demo,关闭 any lint
* docs: demo& ie 兼容问题
* chore: dev-build
|
import { PolygonLayer, Scene } from '@antv/l7';
|
||
import { Map } from '@antv/l7-maps';
|
|||
docs: scale demo & IE 兼容 (#1304)
* docs: 增加demo,关闭 any lint
* docs: demo& ie 兼容问题
* chore: dev-build
|
import React, { useEffect } from 'react';
|
||
import { useData, addLayers } from './useLine';
|
|||
|
|||
export default () => {
|
|||
const { geoData } = useData();
|
|||
|
|||
useEffect(() => {
|
|||
const scene = new Scene({
|
|||
id: 'map',
|
|||
map: new Map({
|
|||
docs: scale demo & IE 兼容 (#1304)
* docs: 增加demo,关闭 any lint
* docs: demo& ie 兼容问题
* chore: dev-build
|
pitch: 0,
|
||
style: 'light',
|
|||
center: [-96, 37.8],
|
|||
zoom: 3,
|
|||
}),
|
|||
});
|
|||
if (geoData) {
|
|||
const layer = new PolygonLayer({})
|
|||
.source(geoData.county, {
|
|||
transforms: [
|
|||
{
|
|||
type: 'join',
|
|||
sourceField: 'id',
|
|||
targetField: 'id',
|
|||
data: geoData.unemploymentdata,
|
|||
},
|
|||
],
|
|||
})
|
|||
.shape('fill')
|
|||
.color('rate', ['#ffffcc', '#b6e2b6', '#64c1c0', '#338cbb', '#253494']) // '#b6e2b6', '#64c1c0', '#338cbb',
|
|||
.style({
|
|||
opacity: 1,
|
|||
});
|
|||
|
|||
scene.addLayer(layer);
|
|||
addLayers(geoData, scene, layer);
|
|||
}
|
|||
return () => {
|
|||
scene.destroy();
|
|||
};
|
|||
}, [geoData]);
|
|||
|
|||
return (
|
|||
<div
|
|||
id="map"
|
|||
style={{
|
|||
height: '500px',
|
|||
position: 'relative',
|
|||
}}
|
|||
/>
|
|||
);
|
|||
};
|