GeoJsonVT 瓦片
L7In addition to the tile services provided by the backend, vector tiles also providegeojson-vtThe tile slicing scheme allows the front end to use vector tiles without back-end support.
Vector Tiles - GeoJsonVT
import { PolygonLayer } from '@antv/l7';
fetch('https://gw.alipayobjects.com/os/bmw-prod/2b7aae6e-5f40-437f-8047-100e9a0d2808.json')
.then((d) => d.json())
.then((data) => {
const source = new Source(data, {
parser: { type: 'geojsonvt', maxZoom: 9 },
});
const polygon = new PolygonLayer({ featureId: 'COLOR' }).source(source).color('red');
});
sourceLayer
When using front-end tile segmentation, we no longer need to specify a data source for the tile layer.
source(GeoJsonData: string, option: IOption)
When using vector tiles split by front-end tiles,sourceThe method receives not the address of the data service, but the standardGeoJSONdata.
option
When using front-end tile segmentation we need tosource parserThe type is set togeojsonvt。
const source = new Source(data, {
parser: {
type: 'geojsonvt',
maxZoom: 9,
geojsonvtOptions: {},
},
});
geojsonOptionsThe following parameters are supported:
| parameter | type | default value | describe | |
|---|---|---|---|---|
| maxZoom | number |
14 |
max zoom to preserve detail on | |
| indexMaxZoom | number |
5 |
max zoom in the tile index | |
| indexMaxPoints | number |
100000 |
max number of points per tile in the tile index | |
| tolerance | number |
3 |
simplification tolerance (higher means simpler) | |
| extent | number |
4096 |
tile extent | |
| buffer | number |
64 |
tile buffer on each side | |
| lineMetrics | boolean |
false |
whether to calculate line metrics | |
| promoteId | `string | null` | null |
name of a feature property to be promoted to feature.id |
| generateId | boolean |
true |
whether to generate feature ids. Cannot be used with promoteId | |
| debug | 0, 1 or 2 |
0 |
logging level (0, 1 or 2) |