Geo Queries with PostGIS in Ionic Angular
PostGIS on Supabase handles geo data for an Ionic Angular app with a Capacitor Google Map. A stores table holds geography(POINT) locations behind a GIST spatial index. Two SQL functions do the geo queries: nearby_stores orders stores by the <-> distance operator and returns st_distance in meters, and stores_in_view filters with && against an ST_MakeBox2D bounding box. The app calls them via Supabase RPC, inserts locations as WKT POINT(long lat) strings, uploads store images to Supabase Storage, and covers the native location permissions and API keys needed for iOS and Android.
Related posts
- Postgres Realtime location sharing with MapLibre
Supabase mediumAdeptLive location sharing is built by having a Telegram bot running in a Supabase Edge Function (grammY on Deno) capture edited-location updates and write them to Postgres through a PL/pgSQL RPC. The RPC looks up the user's active session and stores the coordinates as a PostGIS point. A React/Next.js client subscribes to Supabase Realtime postgres_changes INSERT events, filtered by event_id, and renders markers with react-map-gl and MapLibre GL JS over a Protomaps basemap served from Supabase Storage.
- Building an Uber Clone with Flutter and Supabase
Supabase mediumAdeptAn Uber-style consumer ride app can be built with Flutter on top of Supabase, using PostGIS geography columns to store driver locations and Supabase Realtime to stream the driver's position onto a Google Map. The tutorial walks through the drivers and rides schema, with generated latitude/longitude columns and row-level security policies. A trigger keeps driver availability in sync with ride status, and a security-definer find_driver function uses ST_DWithin and KNN ordering to pick the nearest available driver within 3,000 m and create the ride. On the client, a five-state Flutter UI calls an Edge Function wrapping Google's Routes API to draw the route polyline, compute a fare and subscribe to ride and driver updates.
- Generate Vector Tiles with PostGIS
Supabase mediumAdeptPostGIS can generate Mapbox Vector Tiles on demand from Postgres rows, so a MapLibre GL client can render large point datasets while transferring only the data for the current viewport and zoom level. The pipeline downloads Overture Maps places as GeoJSON, converts them to SQL with GDAL ogr2ogr, and imports them into Supabase with psql. A plpgsql `mvt(z,x,y)` function then uses ST_TileEnvelope, ST_AsMVTGeom and ST_AsMVT to return base64-encoded tiles. A custom MapLibre `addProtocol` handler calls that function through supabase-js RPC. Payloads stay small because names and ids are included only above zoom 13, and detailed metadata is fetched on click instead of being encoded in the tiles.
- Maps with PostgreSQL and PostGIS
Zalando Engineering mediumAdeptPostGIS can generate Mapbox vector tiles directly, so a browser map needs only PostgreSQL/PostGIS, a thin tile server (pg_tileserv) and a Leaflet frontend, with no heavy tiling middleware. The stack runs on Kubernetes: Zalando's Postgres Operator provisions an HA cluster with the PostGIS extension, roles and schemas from a short manifest, and pg_tileserv is deployed with a ConfigMap-mounted TOML config behind an OAuth proxy. Beyond serving tables, SQL function layers built on ST_TileEnvelope, ST_HexagonGrid and ST_AsMVT can produce dynamic hexagon heatmaps (here joined against Geostat population data) whose resolution adapts to the zoom level.
- Roll Your Own Analytics With Astro, Vercel Edge Functions and Neon
Neon mediumAdept
A self-hosted page-view analytics pipeline replaces Google Analytics after GA4 dropped the latitude/longitude reporting dimension. An Astro site deployed to Vercel sends the page slug from a small web component via navigator.sendBeacon to a Vercel Edge Function. The function reads flag, country, city and coordinates with the @vercel/edge geolocation helper and inserts a row into a Neon Postgres table through the serverless driver. Example SQL queries cover top countries and cities, a 30-day geolocation feed for a 3D globe, and daily visit counts. Two caveats: geolocation is null in local dev, and some ad blockers block sendBeacon.