URL & State Synchronization
On /search, the URL is the source of truth for a shareable view. Camera
(center + zoom), the active filters, layout (map/grid), overlay layers, 3D
orientation and the map style are all encoded into the query string, so a copied
link reconstructs the encoded search state — server-side for metadata/OpenGraph
and client-side for the live map. Results can change with data, permissions and
viewport; saved multi-ring regions are not fully represented by an ordinary map URL.
Key files
| File | Role |
|---|---|
src/configs/defaults/params.ts | Camera/presentation parameter registry (@configs/params); filters use their own field names |
src/app/search/[layout]/page.tsx | Server-side parse of filters/camera/point → provider props |
src/app/search/[layout]/_utils.ts | getFiltersFromParams, getCameraFromParams (server) |
src/providers/MapOptionsProvider/MapOptionsProvider.tsx | Client init of style / 3D / layers / camera from searchParams |
src/components/pages/search/MapPageContent.tsx | The write-back effects (pushUrl) |
src/utils/map/urls.ts | getMapUrl, getOrientation, getCoords, getZoom |
src/utils/urls.ts | updateWindowHistory, parseLocationPath |
What’s encoded
Param names live in @configs/params (paramNames) — kept short to keep URLs compact:
- Camera — center is a bare
lat,lngkey (the URL’s first key) plusz(zoom). - Layout — the
[layout]route segment (map/grid). - Overlay layers —
layers(repeatable — schools, etc.). - 3D orientation —
3dasbearing,pitch; a bare?3dactivates 3D with the default pitch. - Map style —
ms(only when it differs from the page default). - Filters — spread by their field names (
minPrice,maxPrice,minBedrooms,minBaths,listingType,listingStatus), plus syntheticq/page/point/polygon/locationId.
How it works
Init (read). Filters, camera and point are parsed server-side in
page.tsx (getFiltersFromParams, getCameraFromParams) and passed as props to
MapOptionsProvider / SearchProvider. On the client, MapOptionsProvider
re-reads searchParams to seed the pieces the map itself owns: mapStyle (only
if the ms value is in the tenant’s mapStyles allowlist), mode3D (only when
the tenant enables 3D), activeLayers, and the initial center/zoom via
getCoords / getZoom.
Write-back. MapPageContent never calls the router — it writes the URL
through updateWindowHistory (a thin window.history.replaceState wrapper),
building the string with getMapUrl. There are two modes:
Filters / camera change → reset page to 1. A change in center, zoom,
filters or point (tracked via a serialized prevParams ref) calls
pushUrl(1).
Layout / layers / 3D / style change → keep the current page. These fire a
separate effect that calls pushUrl(page), preserving pagination.
Both go through window.history directly rather than the Next.js router, so
these writes do not themselves navigate through the router. The state change
that caused a write can independently trigger the search fetching effect.
Gotchas & hints
- First fetch keys off
mapLoaded, notposition.positionis value-deduped inMapOptionsProvider(stablePositionmemoized on a JSON key). Whenmoveendsets the final camera beforeloadfires, themapLoadedfalse→true transition is the only dep that re-runs the fetch effect — somapLoadedmust stay in its dependency array. - Param names must not collide with filter keys. Filters are spread into the
same query namespace, so a param name equal to a filter field (e.g.
style) would clash — hence the short aliases likemsfor map style (see the WARN inparams.ts). window.historyvs the router. State-sync writes useupdateWindowHistory; only real navigations (a new search route) go through the router.
See also: Property Search — How it works and State Management.
Worked traces and evidence
F01 and F02 follow initialization, request
construction, cancellation, result persistence and sharing. Source reviewed at
e30dd9b47 on 2026-11-02; relevant URL/search unit tests were executed. Browser
evidence and its dataset boundary are recorded in Coverage.