代码拉取完成,页面将自动刷新
This library reads Mapbox Vector Tiles and allows access to the layers and features.
var VectorTile = require('@mapbox/vector-tile').VectorTile;
var Protobuf = require('pbf');
var tile = new VectorTile(new Protobuf(data));
// Contains a map of all layers
tile.layers;
var landuse = tile.layers.landuse;
// Amount of features in this layer
landuse.length;
// Returns the first feature
landuse.feature(0);
Vector tiles contained in serialtiles-spec are gzip-encoded, so a complete example of parsing them with the native zlib module would be:
var VectorTile = require('vector-tile').VectorTile;
var Protobuf = require('pbf');
var zlib = require('zlib');
zlib.gunzip(data, function(err, buffer) {
var tile = new VectorTile(new Protobuf(buffer));
});
To install:
npm install @mapbox/vector-tile
An object that parses vector tile data and makes it readable.
layers
property. Optionally accepts end index.{<name>: <layer>, ...}
,
where each layer is a VectorTileLayer
object.An object that contains the data for a single vector tile layer.
Number
, default: 1
)String)
— layer nameNumber
, default: 4096
) — tile extent sizeNumber
) — number of features in the layerVectorTileFeature
) by the given index from the layer.An object that contains the data for a single feature.
Number
) — type of the feature (also see VectorTileFeature.types
)Number
) — feature extent sizeNumber
) — feature identifier, if presentObject
) — object literal with feature propertiesx
and y
properties)[x1, y1, x2, y2]
x
, y
, and z
refer to the containing tile's index.)此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。