| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This library reads Mapbox Vector Tiles and allows access to the layers and features. Depends on pbf v5+.
import {VectorTile} from '@mapbox/vector-tile';
import {PbfReader} from 'pbf';
const tile = new VectorTile(new PbfReader(data));
// Contains a map of all layers
tile.layers;
const landuse = tile.layers.landuse;
// Amount of features in this layer
landuse.length;
// Returns the first feature
landuse.feature(0);Vector tiles contained in serialtiles-spec are gzip-encoded, so a complete example of parsing them with the native zlib module would be:
import {VectorTile} from '@mapbox/vector-tile';
import {PbfReader} from 'pbf';
import {gunzipSync} from 'zlib';
const buffer = gunzipSync(data);
const tile = new VectorTile(new PbfReader(buffer));To install:
npm install @mapbox/vector-tile
An object that parses vector tile data and makes it readable.
An object that contains the data for a single vector tile layer.
An object that contains the data for a single feature.
| Back | FazBrowse Home | New Git URL |