3.1.3 • Published 3 years ago

vt-pbf v3.1.3

Weekly downloads
408,163
License
MIT
Repository
github
Last release
3 years ago

vt-pbf CircleCI

Serialize Mapbox vector tiles to binary protobufs in javascript.

Usage

As far as I know, the two places you might get a JS representation of a vector tile are geojson-vt and vector-tile-js. These both use slightly different internal representations, so serializing each looks slightly different:

From vector-tile-js

var vtpbf = require('vt-pbf')
var VectorTile = require('@mapbox/vector-tile').VectorTile
var Protobuf = require('pbf')

var data = fs.readFileSync(__dirname + '/fixtures/rectangle-1.0.0.pbf')
var tile = new VectorTile(new Protobuf(data))
var orig = tile.layers['geojsonLayer'].feature(0).toGeoJSON(0, 0, 1)

var buff = vtpbf(tile)
fs.writeFileSync('my-tile.pbf', buff)

From geojson-vt

var vtpbf = require('vt-pbf')
var geojsonVt = require('geojson-vt')

var orig = JSON.parse(fs.readFileSync(__dirname + '/fixtures/rectangle.geojson'))
var tileindex = geojsonVt(orig)
var tile = tileindex.getTile(1, 0, 0)

// pass in an object mapping layername -> tile object
var buff = vtpbf.fromGeojsonVt({ 'geojsonLayer': tile })
fs.writeFileSync('my-tile.pbf', buff)

vtpbf.fromGeojsonVt takes two arguments:

  • layerMap is an object where keys are layer names and values are a geojson-vt tile,
  • options is an object (optional argument). There are 2 supported keys: version to define the version of the mvt spec used and extent to define the extent of the tile. version defaults to 1 and extent to 4096.
@simosol/mapbox-gl-js-offlinetilelive-hb-parkingbst-map-gl@mapcreator/mapbox-gl@everything-registry/sub-chunk-3070@langge-data/mapbox-glmosaic-mapnik@visnup/mapbox-gl@xll/mapbox-gl@xt-plugins/mapbox-gl@webdeb/mapbox-gl@xbcx/mapbox-gl@yongju/maplibre-gl@ark-org/map@3drobotics/mapbox-gl@autoxing/mapbox-gl@bcherny/mapbox-gl@curio/mapbox-glcomments-map@datav-gi/datavgi-gl-js@bewithjonam/mapbox-glcadastre-vt@cczbby/mapbox-gl@cczbby/maplibre-gl@carto/mapbox-gl@geops/maplibre-gl@geomatico/mapbox-gl@globalfishingwatch/mapbox-gl@globalfishingwatch/maplibre-gl@globalfishingwatch/map-stylerocad2geojsonocad2geojson-testosm-p2p-vector-tile-indexp-mapbox-glpetr-maplibre-glpbf-basic-rendervizzuality-mapbox-glvnmapvt2pbfvietmap-glvietmaps-glvicapow-mapbox-glviiiivektrackasia-glvtilex-mapbox-glxtal-glxyd-mapbox-gltilelive-otp-routestilelive-otp-stopstilelive-park-apitilelive-geojsontilelive-hsl-parkandridetilelive-hsl-ticket-salestilelive-otp-citybikesthinknetmapsvector-tiles-generatorsupertilersupertiler-nextswsk-mapboxglstore-mvtrpd-mapbox-glrif-mapbox-gl@cgcs2000/mapbox-glcheaper-mapbox-gl-with-referrer-policyelastictiles@inelo/maplibre-gl@dfw810/mapbox-gldata-fair@appearhere/mapbox-gl@emuanalytics/maplibre-gl@hotosm/geojson2vt@hansdo/maplibre-glanthonyhull-mapbox-glanother-mapmagic-glark-map@infinitebrahmanuniverse/nolb-vt@ivelander/mapbox-gldmap-gldeprecation-silencerdiscourse-markdown-itdiscourse-i18ndingi-gl@edenh/mapbox-gl@dtcv/vectortiles@felix5/mapbox-webgl2@goongmaps/goong-js@koopjs/output-vector-tiles@krisdages/mapbox-gl@jingsam/mapbox-glf-mapbox-gl@maps-gl/maps-gl@maptalks/vt@luqh_mapbox/mapbox-glgeojson-tile-servergeojson2mvt@kortxyz/ogcapi-gpkg@mapcat/mapbox-gl@mapgis/mapbox-gl@kantas/vector-js
3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.1

7 years ago

2.1.4

7 years ago

3.0.0

7 years ago

2.1.3

7 years ago

2.1.2

8 years ago

2.1.1

8 years ago

2.1.0

8 years ago

2.0.2

8 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago