wasm-spatial-core
    Preparing search index...

    Function mvtToGeoJson

    • 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 — 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.

      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);

      Parameters

      • bytes: Uint8Array
      • extent: number
      • x: number
      • y: number
      • z: number

      Returns string