back

by uneekname·3y ago·view on hn ↗
I wonder how practical it would be to serve slippy map tiles as SVGs, dynamically generated out of a PostGIS database kind of like this
1 comments
Possible yes, but probably not practical compared to serving unstyled MVT tiles out of PostGIS (ST_AsMVT) and styling them client-side with MapLibre GL JS.

SVG with normal CSS is not enough for styling a map in general. For comparison, here's MapLibre style properties for MVT layers: https://maplibre.org/maplibre-style-spec/layers/

Perhaps it's also solvable without the MVT tooling, but something to watch out for is what happens at tile edges: a polygon is split into two so you need to render tiles that are a bit larger than what's visible (to hide the extra seam at tile boundary); further, a map label may extend over tile boundary so you need a way to allow for that while avoiding collisions between labels from neighbouring tiles.

EDIT: and these are on top of performance issues. Maps are full of detailed geometry where GL leaves SVG far behind.

Geometries in MVT are just points, lines and polygons. These may be associated with zero or more key-values. The default 'viewport' (in SVG terms) is 4096x4096px, with geometries extending beyond this to allow for overlapping text labels, etc.

SVG could represent anything MVT can -- but files would be much larger, as MVT is optimized to store the data efficiently.