Package Exports
- vector-tile
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vector-tile) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
vector-tile-js
This library reads Mapbox Vector Tiles and allows access to the layers and features.
Example
var tile = new VectorTile(data);
// Contains a map of all layers
tile.layers;
var landuse = tile.layers.landuse;
// Amount of features in this layer
landuse.length;
// Returns the first feature
landuse.feature(0);
Depends
- Node.js v0.10.x or v0.8.x
Install
To install:
npm install vector-tile
API Reference
VectorTile
An object that parses vector tile data and makes it readable.
Constructor
- new VectorTile(buffer[, end]) —
parses the vector tile data given a Protobuf buffer,
saving resulting layers in the created object as a
layers
property. Optionally accepts end index.
Properties
- layers (Object) — an object containing parsed layers in the form of
{<name>: <layer>, ...}
, where each layer is aVectorTileLayer
object.
VectorTileLayer
An object that contains the data for a single vector tile layer.
Properties
- version (
Number
, default:1
) - name (
String)
— layer name - extent (
Number
, default:4096
) — tile extent size - length (
Number
) — number of features in the layer
Methods
- feature(i) — get a feature (
VectorTileFeature
) by the given index from the layer.
VectorTileFeature
An object that contains the data for a single feature.
Properties
- type (
Number
) — type of the feature (also seeVectorTileFeature.types
) - extent (
Number
) — feature extent size
Methods
- loadGeometry() — parses feature geometry and returns an array of
Point arrays (with each point having
x
andy
properties) - bbox() — calculates and returns the bounding box of the feature in the form
[x1, y1, x2, y2]