Property Search — How it works
Technical anatomy of the map/search section: providers, components, config, and gotchas. For the user-facing overview see Property Search.
Routes & entry
| Route | Page | Notes |
|---|---|---|
/search | — | Redirects to /search/map. |
/search/[layout] | app/search/[layout]/page.tsx | layout = map or grid. Server component: parses filters/camera/point/polygon (or a searchId saved search), gates on features.map, mounts the providers, renders MapPageContent. |
Root component: src/components/pages/search/MapPageContent.tsx.
Providers
Mounted in the route (app/search/[layout]/page.tsx), outermost → innermost:
MapOptionsProvider map camera / style / layout / 3D; splits into 5 contexts:
│ useMapOptions, useMapLocations, useMapLayers,
│ useMapPopup, useMapPopupActions
└─ SearchProvider filters, results, clusters, multi-units; split contexts:
│ useSearch (read-heavy) vs useSearchActions (write-stable)
└─ AiSearchProvider AI image/feature search; syncs its selections into SearchProvider
└─ PageTemplate (noFooter) → MapPageContentThese are scoped to the search section (not global). The global tree
(UserProvider, DialogProvider, SnackbarProvider, feature-gated favorites/…) is
described in State Management.
SearchProvider deliberately exposes two contexts so filter writers
(useSearchActions) don’t re-render when results (useSearch) change. Read
from the narrowest hook you need.
Component tree
MapPageContent owns the fetch effect + URL sync
├─ MapFilters filter bar (top)
│ ├─ AutosuggestionField location type-ahead
│ ├─ AiSearchButton image/feature AI search entry
│ ├─ AdvancedFiltersButton opens the advanced-filters dialog
│ └─ SaveSearchButton persists the current filter set
└─ MapRoot (memoized) map + list orchestrator
├─ OverlayLayersController overlay (schools/…) GL layers
├─ MapContainer (@shared/Map) Mapbox canvas; listing markers via useListingMarkers
├─ MapControls zoom / compass / 3D / draw / layers / style / locate buttons
├─ SunriseSliderContainer { SunriseSlider, CalendarSlider } — shadows/time (tenant)
├─ MapTitle · SaveSearchCanvas
├─ SelectedLocationsBar mobile: the selected-location chips at the bottom edge
├─ FloatingLayoutSwitch mobile: `MapLayoutSwitch variant="floating"` over the map —
│ Chat | Map | List with `aiChat`, else one Map/List button
├─ ListingDrawer mobile: tapped-marker listing preview
├─ GridDesktopContainer | GridMobileDrawer
│ ├─ GridFilters
│ ├─ GridContent the card grid
│ └─ ChatContent AI chat panel — `features.aiChat` (mobile: its own GridMobileDrawer)
├─ ListingBrowserDialog wide-desktop: paged listing browser
├─ SaveSearchDialog `features.saveSearch`
├─ SupportAgent EVAS agent iframe — `features.aiAgent`
└─ OverlayMarkerPopup · ListingPopupHostMapRoot also runs the map-side hooks that render nothing: useParcelListings (parcels
mode), usePoint (the address pin, or the radius circle of a point with a radius), and
useOverlayPolygonGuard.
Files live under src/components/pages/search/ (MapPageContent.tsx,
components/MapFilters/, components/MapRoot/). The map canvas, markers, controls and
popups are shared: src/components/shared/Map/ — see
Shared Components.
Configuration
| Config | Drives |
|---|---|
@configs/map | Initial camera (mapboxDefaults), controls (position, mobilePosition, compass, and the colors palette every MapControlButton paints from), searchArea boundary, overlays, marker.clusterPosition (cluster markers at the API centroid or the bounds center). An overlay with external (resolveLocation + filterToken) makes its markers selectable as external locations persisted via externalLocationId. |
@configs/search | Paging, clustering, MLS board routing, autosuggestPosition, extractLocationPolygons. |
@configs/filters | defaultFilters, the type-selector listingTypes list, which advanced-filter slots render, priceInputs (the price picker reads its range in two editable inputs instead of labels on the thumbs), and soldPriceAndDate (a sold range filtered by the sold price and “Newest to Oldest” ordered by sale date). |
@configs/params | URL-param shorthand names for the shareable search state. |
@configs/cards-grids | mapTopOffset and grid sizing. |
@configs/ai-agent | headlessIframeId for the EVAS agent. |
@configs/features | Gates map, aiChat, aiAgent, saveSearch, blurRestrictedProperty. |
Gotchas & hints
- Raw-field filters: a dialog tab, shown while a tenant lists any field. The lists in
configs/defaults/filters.tsare the sample-data board’s (110): 39 sale / 38 lease RESO fields more than 2% of a type’s active listings fill. Every other tenant inherits them through...defaults, so its ownfilters.tsempties both (rawFilters: { ...defaults.rawFilters, sale: [], lease: [] }); a new tenant has to do the same. The URL parser admitsraw.<Field>params of the listed fields only, so an empty list also keeps a pastedraw.link inert. - Raw-field filters match exactly unless
rawFilters.containsis on. The advanced dialog’s Features tab (@configs/filtersrawFilters:sale/leasefield lists,previewMatches) sendsraw.<Field>=<value>. On board 110 values are RESO arrays, so an exact value reaches every listing that holds it. Boards that file a multi-value field as one comma-joined string (REBNY:"InUnit,SeeRemarks") match a value only when it stands alone — In unit reaches 354 of 4,500 holders, every PetsAllowed value 0.contains: truemakesprocessParamssendcontains:<value>; the URL and checkboxes keep the plain value. It over-matches where one value contains another (none→ BuildingNone). Evidence:docs/design/serhant/advanced-search-spec.md§3.5. - First fetch hinges on
mapLoaded.positionis value-deduped inMapOptionsProvider, so whenmoveendsets the final camera beforeloadfires, themapLoadedfalse→true transition is the only thing that dispatches the initial fetch — it must stay in the effect deps (MapPageContent). - Two controls stacks.
MapControlsStacktakes an optionalposition/mobilePositionprop (default from@configs/mapcontrols). The defaultMapControlsrenders two: the main stack, and a<MapControlsStack position="top-right" mobilePosition="top-right">holding only theMapLocateButtonGPS “locate me” button. - Map markers = top-level results + inlined small-cluster listings. They are deduped
(
dedupeListings) because the API can return both;boardIdis backfilled in the Search service so the inlined twin collapses onto the top-level key. Miss this and you get phantom duplicate markers / a hung listing browser. - Cluster markers sit at the API centroid.
cluster.locationis the mean of the cluster’s listings;@configs/mapmarker.clusterPosition: 'boundsCenter'moves the marker to the middle ofcluster.boundsinstead. Either way a click fitscluster.bounds. - Board routing is per-listing. A listing whose board is in
@configs/searchdistinctBoardIdsis fetched and linked with that board, spelled out bygetSeoUrlas a trailing-{boardId}suffix so a direct visit reads the record the link was built from; everything else routes todefaultBoardIdand links without a suffix. A tenant may listdefaultBoardIditself, which makes every board explicit in its URLs instead of leaving one implicit (MoveSmartly lists all three: 2, 90, 91). A URL without a suffix always readsdefaultBoardId, which is what keeps links minted before a board joined the list working. - Collapsing boards can trade away visibility, not just richness. MoveSmartly’s boards are
specialized: VOW (90) holds the sold archive and gates it behind registration
(
permissions.displayPublic: N), IDX (91) publishes the active listings and carries the room breakdown VOW omits. Collapsing an IDX record onto VOW handed a guest a gated copy of a listing they had just been shown on the map — hence every board being addressed explicitly for that tenant. Before collapsing a tenant’s boards, check what each board’s copy actually contains. - A listing link carries whatever board the search returned. Cards build their href with
getSeoUrl(listing), and the frontend sends noboardIdfilter, so the board in the URL is the one Repliers picked for that record — it returns one copy per property in a geo search, and which board that is follows the data (a MoveSmartly sample: active listings came back on IDX 91, sold ones on VOW 90). Two consequences once every board is spelled out: a link minted before the change carries no suffix, so it readsdefaultBoardIdand the PDP canonicalizes it to that board’s URL; and if the search returns a different board’s copy than the suffix-less URL loads, one property ends up with two canonical URLs — the old one pointing atdefaultBoardId, the fresh links and the sitemap at the board the search returned. Collapsing them for good needs the detail request to prefer the copy a guest may actually see, which is a backend decision, not a routing one. - Markers are imperative DOM, not React.
useListingMarkerswires plain DOM click handlers, so their callbacks read component state through refs (multiUnitsRef,mapListingsRef), not live React state. - Listing markers are DOM; overlays/polygons are GL. The map canvas mixes a DOM marker
layer (listings) with GL layers (overlays, draw polygons) — see
@shared/Map. - URL sync has two modes. Changing filters or camera resets the page to 1; changing
layout / overlay layers / 3D / style keeps the page and writes
window.historydirectly (not the Next router). MapRootis memoized so toggling an overlay layer (which re-rendersMapPageContentfor URL sync) doesn’t re-render the heavy map subtree; the layers menu updates via its ownuseMapLayerssubscription.- Feature gates render inline:
aiChat→ChatContent,aiAgent→SupportAgent,saveSearch→SaveSearchDialog,blurRestrictedProperty→ address-label restriction on style load. - External overlay selections ride POST
queries. Selecting an external-source overlay marker (e.g. a MoveSmartly school) storesexternalLocationId=<overlayId>-<rest>in the URL; on load the owning overlay’sexternal.resolveLocationrebuilds the location and its merged (Multi)Polygon. The listings request then switches toqueries:[{ locationId, map: region }, { map: clippedExternalPolygons }]— queries UNION while params inside one query AND. Never emit a top-levelmaptogether with a querymap(Repliers rejects the conflict with a 400), and never letexternalLocationIdreach the API —getSearchAreastrips it (plus a defensive strip inprocessParams). - Changing an overlay’s filter options drops its selected external locations (same rule
as hiding the layer): the id’s trailing filter token no longer matches
external.filterToken(options)— enforced byuseExternalSelectionReset. - Two kinds of user-defined region.
SearchProvider.polygonis the draw tool’s state: exactly ONE editable ring, URL-persisted (polygon=).SearchProvider.regionis the multi-ringmapof a loaded saved search: read-only (the one-ring draw editor can’t represent it) and NOT URL-persisted (merged location boundaries are far beyond URL size limits — it survives filter changes but not a reload, like the saved-search title). They are separate fields by design: wideningpolygoninto a union would push array-depth sniffing into the draw editor, the URL sync and every consumer, for a state with a different lifecycle. Shared touchpoints stay shared: both clear viaclearPolygon, both feedgetSearchArea(accepts either depth), both render on the'user'source. Single-ring saved searches keep loading as the editablepolygonfor back-compat. - Listing types map to
{ class, propertyType, style }, not just a propertyType list. Each type is a query fragment in@configs/filterslistingTypeDeclaration. A tenantdeepmerges the default declaration with array-overwrite and states only the axes that differ ([]removes an axis); thelistingTypetransformer merges the fragments of the selected keys.services/Search/listingTypeDeclaration.tsbuilds the runtime declaration: the types the tenant renders inlistingTypes, plus the derivedpenthouse/loftsearch shortcuts (fromcondo) andallListings. The generictownhomekey is class-agnostic on purpose. A tenant that needs townhouses split by property class declares dedicated keys —residentialTownhome(class: residential) andcondoTownhome(class: condo, with a condo-onlypropertyType) — and lists them in place oftownhomein its selector (MoveSmartly).ListingTypecomes from theavailableListingTypessuperset (not the defaultlistingTypesarray), so granular/virtual keys type-check without appearing in the default selector. New keys also need aLocationHeader.titlebranch in i18n or the SEO title falls back to “Real Estate”. Location-page slugs resolve throughparseListingType(app/locations/[[...slugs]]/_utils), which is tenant-guarded: atownhomesslug (orcondos+townhomes) maps to the class-scoped type only when the tenant’slistingTypesexpose it, otherwise it stays the class-agnostictownhome. - The generic
otherkey folds every leftover propertyType into one button. A tenant that wants a catch-all “Other” filter listsotherin itslistingTypesand declares it in itslistingTypeDeclarationas{ propertyType: [...] }(noclass/style). No other tenant needs an entry. BecauseallListingsis the union of the rendered types, those propertyTypes also surface under “All Listings”.otheris innoEstimationTypes(@configs/estimate) — a mixed bucket isn’t a single estimatable type. Example: URBN groupsCommercial Industrial,Manufactured On Land,Manufactured Home,Farm & Ranch,Timeshare,Boat Slip,Otherhere. - Hiding a type button drops its propertyTypes from “All Listings”.
allListingsis derived —class: [residential, condo]plus the union of thepropertyTypes of the types the tenant renders — so a type left out oflistingTypescontributes nothing to it, even when the tenant inherits its declaration from the defaults. Its listings stay reachable only if another rendered type declares their propertyType. URBN drops thebusiness/commercial/semiDetachedbuttons this way: NWMLS commercial listings live inother, and semi-detached styles (Duplex/Triplex/Quadruplex) already carrypropertyType: Multi Family, so themultiFamilybutton returns them. The marker icon still classifies by scrub-safeclass:commercial()falls back toclass === 'CommercialProperty'when the declared propertyTypes don’t match. Legacy URL / saved-search values for the removed buttons are remapped for display only viavalueFallbacksin the tenant’sListingTypeSelectfork. The value itself has no entry in the runtime declaration (only rendered types do), so the query it produces carries no type constraint. Because a tenant’sListingTypeis theavailableListingTypessuperset, dropping a button never breaks shared code that still references the key. - Multi-type selection can UNION via POST
queries(unionListingTypes). By default the selected types are flattened into one top-level filter: every type’sclass,propertyTypeandstyleare concatenated and sent as a single AND. That is correct only when the types share an axis. When they don’t — e.g. a tenant’stownhomeis astylewhileresidentialis apropertyType— the flat AND becomes an intersection (residential AND style=Townhouse), collapsing the result to near-zero instead of unioning the two groups. SettingunionListingTypes: true(in@configs/filters; requiresmultiListingType: true) switches the adapter to emit oneRawQueryper selected type and send them as POSTqueries(OR).applyListingTypeUnion(services/Search/adapter.ts) builds them, strips the movedclass/propertyType/styleoff the top level (a param insidequeriescannot also sit at the top level — Repliers returns a 400), and cartesian-combines with any pre-existing overlayqueries((O1∨O2) ∧ (T1∨T2)). Top-level scalars (price, beds, status) and the viewportmapstill AND across the whole union. A single selected type keeps the flat path. Defaultfalse. - A sold range can filter by sold price and sort by sold date (
soldPriceAndDate). By default the price filter bounds the list price (minPrice/maxPrice) and “Newest to Oldest” (createdOnDesc) orders by list date, over a sold range too. WithsoldPriceAndDate: true(in@configs/filters), a chosensoldRangemakesprocessParamssendminSoldPrice/maxSoldPriceand the sold-date sort token (soldDateDesc) instead. Defaultfalse.
Workflow and verification
Source review: e30dd9b47, 2026-11-02. The cross-layer guide covers URL parsing, viewport geometry, adapter output, cancellation, response storage and sharing. Selected search/API tests and a defaults/sample-data browser replay were executed.