Decode an MVT tile and convert all features to GeoJSON with WGS84 coordinates.
Transforms tile-space coordinates to geographic WGS84 (longitude, latitude) using the Web Mercator (EPSG:3857) inverse projection.
bytes
extent
x
y
z
A GeoJSON FeatureCollection string with WGS84 coordinates.
const response = await fetch('/tiles/10/868/387.pbf');const geojson = mvtToGeoJson(new Uint8Array(await response.arrayBuffer()), 4096, 868, 387, 10); Copy
const response = await fetch('/tiles/10/868/387.pbf');const geojson = mvtToGeoJson(new Uint8Array(await response.arrayBuffer()), 4096, 868, 387, 10);
Decode an MVT tile and convert all features to GeoJSON with WGS84 coordinates.
Transforms tile-space coordinates to geographic WGS84 (longitude, latitude) using the Web Mercator (EPSG:3857) inverse projection.
Parameters
bytes— Raw MVT protobuf bytes.extent— Tile extent (typically 4096).x— Tile column (x coordinate in the slippy map scheme).y— Tile row (y coordinate in the slippy map scheme).z— Zoom level.Returns
A GeoJSON FeatureCollection string with WGS84 coordinates.
Usage (JS)