Supabasesimon_grimmTutorial
Geo Queries with PostGIS in Ionic Angular
Summary
This tutorial shows how to build an Ionic Angular cross-platform app that stores and queries store locations with Supabase and PostGIS. It enables PostGIS, defines a stores table with a geography(POINT) location, adds a GiST spatial index, creates storage policies, and seeds example coordinates. SQL functions named nearby_stores and stores_in_view calculate distances or select stores inside a coordinate box, while Ionic uses Capacitor Google Maps and geolocation to display markers and query nearby data. The app also uploads store images to Supabase Storage, retrieves them with a 300-pixel contain transformation, and opens store details in an Ionic bottom-sheet modal after marker selection. The completed code is provided on GitHub and requires project and Google Maps credentials plus the included SQL.
Context
The tutorial addresses storing latitude and longitude data and querying distances or geographic areas for an application. It states that directly storing coordinates and querying them is not very effective or scalable, motivating the use of PostGIS data types and spatial indexes.
Approach / What changed
Enable the PostGIS extension in Supabase, create a stores table with a geography(POINT) column and GiST index, and define nearby_stores and stores_in_view database functions. Build the client with Ionic Angular, Capacitor Google Maps and geolocation, Supabase Storage, native location permissions, and marker-driven store detail loading with image transformations.
Takeaways
The stores table uses a geography(POINT) location column, and a GiST index is created on that column for more performant geographic queries.
The nearby_stores function returns stores with distances in meters and orders them using the location-distance operator; stores_in_view filters locations within a coordinate box.
Supabase Storage serves store images through getPublicUrl with a 300-pixel contain transformation, and marker selection loads the store details into an Ionic bottom-sheet modal.
Source and freshness
- Source
- supabase.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.