Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/developmentseed/cached-vector-tile
https://github.com/developmentseed/cached-vector-tile
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/developmentseed/cached-vector-tile
- Owner: developmentseed
- License: bsd-3-clause
- Created: 2016-08-19T15:46:44.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-19T16:21:10.000Z (about 8 years ago)
- Last Synced: 2024-05-18T19:31:02.761Z (6 months ago)
- Language: JavaScript
- Size: 108 KB
- Stars: 7
- Watchers: 46
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-vector-tiles - cached-vector-tile - An alternative implementation of the vector-tile-js interface, backed by plain JS objects/arrays rather than parsed-on-demand protobuf data. Trades away memory efficiency for faster feature.loadGeometry() calls. (Parsers & Generators)
README
# cached-vector-tile [![CircleCI](https://circleci.com/gh/developmentseed/cached-vector-tile.svg?style=svg)](https://circleci.com/gh/developmentseed/cached-vector-tile)
An alternative implementation of the [vector-tile-js](https://github.com/mapbox/vector-tile-js) interface that is backed by plain JS objects/arrays rather than parsed-on-demand protobuf data. Trades away memory efficiency for faster feature.loadGeometry() calls.
## Install and Use
`npm install cached-vector-tile`
```js
var Protobuf = require('pbf');
var VectorTile = require('vector-tile').VectorTile
var CachedVectorTile = require('cached-vector-tile')var vt = new VectorTile(new Protobuf(rawdata))
var cached = new CachedVectorTile(vt)
var plain = cached.serialize()
// 'plain' is a plain JS object, suitable for JSON.serialize() or storage in
// something like IndexedDB
```## API
### CachedVectorTile
A vector tile. Implements the interface defined in the [vector-tile-js API reference](https://github.com/mapbox/vector-tile-js) (except that the constructor is different).
**Parameters**
- `vt` **(VectorTile | [CachedVectorTile](#cachedvectortile) \| [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** The vector tile to clone. Can be a [vector-tile-js](https://github.com/mapbox/vector-tile-js) tile, a CachedVectorTile, or a plain JS object as serialized by [CachedVectorTile#serialize](#serialize)
- `properties` **\[[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)]** An optional object mapping feature ids to property values. If provided, these properties will be used instead of the ones present in vt's features.#### serialize
Returns a plain JS object representation of the vector tile.
### CachedVectorTileLayer
A vector tile layer. Implements the interface defined in the [vector-tile-js API reference](https://github.com/mapbox/vector-tile-js)
#### serialize
Returns a plain JS object representation of the vector tile layer.
### CachedVectorTileFeature
A vector tile feature. Implements the interface defined in the [vector-tile-js API reference](https://github.com/mapbox/vector-tile-js).
#### serialize
Returns a plain JS object representation of the vector tile feature.