Property search is the feature buyers touch most in any real estate app, and it is also the feature most teams underestimate. A list of listings with a price filter is easy. A map that stays fast while a user drags across a city, with thousands of pins, live filters and accurate results, is a different engineering problem.
This guide walks through how to build map-based property search that holds up in production: the data model, the geospatial query, clustering, filter design and the mistakes that slow most builds down.
Quick answer
Store listing coordinates as a geospatial type, index them with a spatial index (GiST in PostGIS or a 2dsphere index in MongoDB), query by the visible map bounding box rather than by radius, cluster pins on the server when the zoom level is low, and debounce map movement so the client sends one request per settled viewport instead of dozens per drag.
What does the data model need?
Start with a listings table that keeps location data in a proper spatial column, not two loose float fields.
CREATE EXTENSION IF NOT EXISTS postgis; CREATE TABLE listings ( id BIGSERIAL PRIMARY KEY, title TEXT NOT NULL, price INTEGER NOT NULL, bedrooms SMALLINT, bathrooms SMALLINT, property_type TEXT, status TEXT DEFAULT 'active', location GEOGRAPHY(Point, 4326) NOT NULL, updated_at TIMESTAMPTZ DEFAULT now() ); CREATE INDEX idx_listings_location ON listings USING GIST (location); CREATE INDEX idx_listings_filters ON listings (status, property_type, price); Two indexes matter here. The GiST index makes the spatial lookup cheap, and the composite index on status, type and price lets the planner cut the result set before it touches geometry.
Why query by bounding box instead of radius?
A radius query answers "what is near this point", but users on a map are asking "what is inside what I can see". The viewport is a rectangle, so query the rectangle.
SELECT id, title, price, bedrooms, ST_Y(location::geometry) AS lat, ST_X(location::geometry) AS lng FROM listings WHERE status = 'active' AND price BETWEEN $1 AND $2 AND location && ST_MakeEnvelope($3, $4, $5, $6, 4326)::geography LIMIT 500; The && operator checks bounding-box overlap and uses the GiST index directly. It is much faster than computing distances for every row, and it matches what the user sees on screen.
How do you handle thousands of pins?
Sending 8,000 markers to a phone is the fastest way to freeze the map. Use two modes based on zoom level:
- Low zoom (city or region view): return clusters. Group listings into grid cells on the server and send one marker per cell with a count.
- High zoom (street view): return individual listings, capped at a sensible limit.
PostGIS can cluster in a single query:
SELECT COUNT(*) AS total, ST_Y(ST_Centroid(ST_Collect(location::geometry))) AS lat, ST_X(ST_Centroid(ST_Collect(location::geometry))) AS lng FROM listings WHERE status = 'active' AND location && ST_MakeEnvelope($1, $2, $3, $4, 4326)::geography GROUP BY ST_SnapToGrid(location::geometry, $5); The grid size ($5) should shrink as the zoom level increases. A simple lookup table from zoom level to grid size works well and is easy to tune.
How should the client call the API?
Map libraries fire move events constantly during a drag. Debounce them so a request goes out only after the map settles.
let timer; map.on('moveend', () => { clearTimeout(timer); timer = setTimeout(() => { const b = map.getBounds(); fetchListings({ west: b.getWest(), south: b.getSouth(), east: b.getEast(), north: b.getNorth(), zoom: map.getZoom(), ...activeFilters }); }, 300); }); Also cancel in-flight requests with an AbortController when a new one starts. Without it, a slow response for an old viewport can arrive late and overwrite fresh results.
What filters do buyers use most?
Keep the first release focused on filters that change decisions: price range, bedrooms, bathrooms, property type and listing status. Add commute time, school zones or saved-area drawing later, once the core query is stable. Every extra filter is another index decision, so add them deliberately.
Which mistakes slow most builds down?
- Storing latitude and longitude as plain floats. You lose spatial indexing and end up writing distance maths in application code.
- Returning full listing objects on the map call. The map needs id, price and coordinates. Load photos and descriptions only when a user taps a pin.
- Skipping cache headers. Popular viewports repeat often. A short cache on the bounding-box endpoint takes real load off the database.
- Ignoring data freshness. Listings feed in from MLS or partner APIs on a schedule. Track
updated_atand hide stale or sold listings quickly, because a sold home on the map erodes trust faster than any bug.
Security and data handling
Property apps hold more personal data than teams expect: saved searches, viewing requests, mortgage enquiries and agent messages. Encrypt data in transit and at rest, rate-limit search endpoints to stop scraping of listing data, and respect the licence terms of any MLS feed you consume, since most restrict how listing data can be stored and displayed.
Where to go next
Map search is one layer of a full product. Agent dashboards, lead routing, virtual tours and document signing all sit on top of it. Teams planning the full build can review how a real estate app development project is usually scoped, from MVP to a multi-role platform.
FAQ
Is PostGIS required for property search?
No. MongoDB with a 2dsphere index or Elasticsearch with geo_point fields can also work. PostGIS is a strong default when your listing data is already relational.
How many pins can a mobile map show smoothly?
It depends on the device and library, but a few hundred individual markers is a safe ceiling. Beyond that, switch to clustering.
Should search run on the client or the server?
On the server. Client-side filtering only works for small, static datasets and breaks as soon as listings update often.
