Please help me!This is very important to me.
My code is as below,when read a pbf file,success to create a pbf object,when request on web,failed to create.Same two files!
How can I do?Help!
var fs = require('fs');
var VectorTile = require('@mapbox/vector-tile').VectorTile;
var request = require('request');
var rp = require('request-promise');
function filetest() {
var data = fs.readFileSync('49.mvt');
var tile = new VectorTile(new Protobuf(data));
var layerNames = Object.keys(tile.layers);
console.log('file tile layers:', layerNames);
}
function urltest() {
rp({
url: 'http://124.70.193.2:6082/49.mvt',
method: "GET",
}).then(function (res) {
var pbf = new Protobuf(res);
var tile = new VectorTile(pbf);
var layerNames = Object.keys(tile.layers);
console.log('url tile layers:', layerNames);
});
}
urltest();
filetest();
Please don't use GitHub to ask generic development questions, there is StackOverflow for this. Request returns a string as response by default, you need to set encoding: null in the options probably.
Please help me!This is very important to me. My code is as below,when read a pbf file,success to create a pbf object,when request on web,failed to create.Same two files! How can I do?Help!
below is output: file tile layers: [ 'xian', 'cun' ] url tile layers: []