Examples
GeoParquet 2.0 in the Browser
One 19.8 MB GeoParquet 2.0 file holds every building of Rhode Island (263,000 rows, 6 row groups). The footer gives a bounding box per row group, so the map downloads only the groups in view. No server, no tiles, no WASM. Fly to another town and watch the next row group load.
Installation
$ npx shadcn-vue@latest add https://mapcn-vue.geoql.in/r/mapUsage
<script setup lang="ts">
import { VMap, VControlScale, VLayerMaplibreGeojson } from '@geoql/v-maplibre';
import { asyncBufferFromUrl, parquetMetadataAsync, parquetReadObjects } from 'hyparquet';
import { decompress } from 'fzstd';
// 1. Read the footer only (one range request).
const file = await asyncBufferFromUrl({ url });
const metadata = await parquetMetadataAsync(file);
// 2. GeoParquet 2.0: each row group has a bounding box for the native
// GEOMETRY column. No bbox column is needed.
let rowStart = 0;
const groups = metadata.row_groups.map((group) => {
const { bbox } = group.columns
.find((c) => c.meta_data.geospatial_statistics)
.meta_data.geospatial_statistics;
const rows = Number(group.num_rows);
return { bbox, rowStart, rowEnd: (rowStart += rows) };
});
// 3. After each map move, read only the row groups the view touches.
// hyparquet decodes GEOMETRY (WKB) to GeoJSON geometries.
async function load(group) {
const rows = await parquetReadObjects({
file, metadata,
columns: ['geometry', 'building'],
rowStart: group.rowStart, rowEnd: group.rowEnd,
compressors: { ZSTD: (input, n) => decompress(input, new Uint8Array(n)) },
});
loaded.value.push({
type: 'FeatureCollection',
features: rows.map((row) => ({
type: 'Feature', geometry: row.geometry, properties: { building: row.building },
})),
});
}
</script>
<template>
<VMap :options="mapOptions" class="h-125 w-full" @loaded="onLoaded">
<VControlScale position="bottom-left" />
<VLayerMaplibreGeojson
v-for="(data, i) in loaded"
:key="i"
:source-id="`buildings-${i}`"
:layer-id="`buildings-${i}`"
:source="{ type: 'geojson', data }"
:layer="{ type: 'fill', paint: { 'fill-color': '#5eccE6' } }"
/>
</VMap>
</template> Components 3
<VMap />@geoql/v-maplibre<VControlScale />@geoql/v-maplibre<VLayerMaplibreGeojson />@geoql/v-maplibre