-
-
Save jfirebaugh/2b08234d2587ce2f33a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var vt = require('vector-tile'); | |
var Protobuf = require('pbf'); | |
var zlib = require('zlib'); | |
request({url: 'http://b.tiles.mapbox.com/v4/bognerstephan.bebfd75b/12/2152/1411.vector.pbf?access_token=pk.eyJ1IjoiYm9nbmVyc3RlcGhhbiIsImEiOiJBMnlqbnZrIn0.YwiGRgpheNMPujZn-JBh6Q', encoding: null}, function(error, response, body) { | |
if (!error && response.statusCode >= 200 && response.statusCode < 300) { | |
zlib.gunzip(body, function(err, body) { | |
var ab = new ArrayBuffer(body.length); | |
var view = new Uint8Array(ab); | |
for (var i = 0; i < body.length; ++i) { | |
view[i] = body[i]; | |
} | |
var tile = new vt.VectorTile(new Protobuf(new Uint8Array(ab))); | |
var layer = tile.layers["stuttgart-rails"]; | |
for (var i = 0; i < layer.length; i++) { | |
layer.feature(i); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment