mapbox-vector-tile
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

vector-tile

This library reads Mapbox Vector Tiles and allows access to the layers and features.

It is based on @mapbox/vector-tile with the following differences:

  • this library does not depend on @mapbox/point-geometry,
  • this library uses protobuf-ts to decode protos,
  • this library is written in TypeScript,
  • this library provides Feature.asPoint(), Feature.asLine(), Feature.asPolygon() to make it easier to work with geometries.

Install

npm i --save mapbox-vector-tile

Example

import { VectorTile } from 'mapbox-vector-tile';
 
// data is either a Buffer or a Uint8Array containing binary data.
const tile = new VectorTile(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);

Notes

  • 64-bit numbers could be returned as number (the default), string or bigint. You can specify the format using the second parameter of VectorTile.
  • The features id are always returned as a numerical string.

Changes

0.3.0 - Oct 22, 2020

Readme

Keywords

none

Package Sidebar

Install

npm i mapbox-vector-tile

Weekly Downloads

58

Version

0.3.0

License

MIT

Unpacked Size

98.5 kB

Total Files

14

Last publish

Collaborators

  • victorb