How to use the vt-pbf.fromVectorTileJs function in vt-pbf

To help you get started, we’ve selected a few vt-pbf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github philippeauriach / vector-tiles-generator / index.js View on Github external
.then(function(layers) {
    var pbfOptions = {};
    for(var i in layers) {
      var layer = layers[i];
      if(layer.pbf){
        //construct the GeoJSONWrapper here, so that we can tell him the version !
        pbfOptions[layer.name] = new GeoJSONWrapper(layer.pbf.features);
        pbfOptions[layer.name].name = layer.name;
        pbfOptions[layer.name].version = 2;
      }
    }
    if(pbfOptions.length === 0) {
      return undefined;
    }
    // we use fromVectorTileJs instead of fromGeojsonVt because we constructed the GeoJSONWrapper ourselves
    var buff = vtpbf.fromVectorTileJs({layers: pbfOptions});
    if(buff) {
      buff = new Buffer(buff.buffer);
    }
    return buff;
  });
};

vt-pbf

Serialize mapbox vector tiles to binary protobufs in javascript.

MIT
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis

Similar packages