fill
The simplest representation of a geometry layer on a map is a fill map, which fills a specified area with a specified color.
accomplish
Let’s introduce how to draw a simple filled diagram.
- you can
L7Found on the official websiteOnline case
import { Scene, PolygonLayer, LineLayer, Popup } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';
const scene = new Scene({
id: 'map',
map: new GaodeMap({
style: 'light',
center: [-96, 37.8],
zoom: 3,
}),
});
scene.on('loaded', () => {
fetch('https://gw.alipayobjects.com/os/basement_prod/d36ad90e-3902-4742-b8a2-d93f7e5dafa2.json')
.then((res) => res.json())
.then((data) => {
const color = [
'rgb(255,255,217)',
'rgb(237,248,177)',
'rgb(199,233,180)',
'rgb(127,205,187)',
'rgb(65,182,196)',
'rgb(29,145,192)',
'rgb(34,94,168)',
'rgb(12,44,132)',
];
const layer = new PolygonLayer({})
.source(data)
.scale('density', {
type: 'quantile',
})
.color('density', color)
.shape('fill')
.active(true);
const layer2 = new LineLayer({
zIndex: 2,
})
.source(data)
.color('#fff')
.active(true)
.size(1)
.style({
lineType: 'dash',
dashArray: [2, 2],
});
scene.addLayer(layer);
scene.addLayer(layer2);
});
});
source
It is recommended to use the standard geometry layerGeoJSONdata.
shape
Draw a filled diagram, the shape isfillConstant, data mapping is not supported
layer.shape('fill');
size
Fill image does not need to be setsize;
style
opacityLinearSets the radial gradient of the geometric fill.
style({ opacity Linear: { enable: true, // true - false dir: 'in', // n - out },
});
raisingHeightset up3DThe elevation of the fill pattern.