Size
line layersizeMethod can set the width and height of the line.
ILineSize: number | [number, number]
- If the size type is number, it represents the width of the line
- The size type is [number, number] representing width and height respectively.
lineLayer.size(1); // The width of the line is 1
lineLayer.size([1, 2]); // Width is 1, height is 2
size(width: ILineSize)
The width value of the line layer can be set directly. All lines in the layer use one width.
layer.size(2);
size(field: string)
The width of the line layer can be mapped based on the data values accepted by the layer, accepting fields of incoming data as arguments.
layer.source({
type: 'Feature',
properties: {
lineSize: 2,
},
geometry: {
type: 'LineString',
coordinates: [
[119.988511, 30.269614],
[119.9851, 30.269323],
[119.99271, 30.22088],
],
},
});
layer.size('lineSize');
size(field: string, domain: ILineSize[])
sizeMethod supports simple value mapping and will be based onfieldThe values extracted from the data passed into the layer are mapped todomainin the value range.
layer.size('type', [1, 2, 3]);
size(field: string, callback: () => ILineSize )
sizeThe method supports the writing method of callback function, which will be based onfieldascallbackmethod parameters,callbackThe return value of the method is the actual width and height of the line layer.
layer.size('type', (value) => {
switch (value) {
case 'path':
return 1;
case 'road':
return 2;
}
});