Location Pages — How it works
Technical anatomy of the locations catalog. Overview: Location Pages.
Routes & entry
| Route | Page root |
|---|---|
/locations | @pages/locations/LocationsPageContent |
/locations/[[...slugs]] | @pages/locations/LocationsPageContent |
Providers
LocationsPageContent mounts LocationProvider (useLocationPage, useLocationMap) with
the location, its child locations (areas/cities/hoods), nearby locations, and listing count.
See State Management.
Component tree
LocationsPageContent
└─ LocationProvider
└─ LocationsPageLayout
├─ header → LocationHeader
├─ filters → LocationFilters
├─ footer → LocationFooter
└─ content
├─ CardSurface → ListingCard ×N (SkeletonCard while loading)
├─ EmptyCatalogListings (when no listings)
├─ LocationPagination
├─ LocationBreadcrumbs
└─ FiltersListListings are server-rendered when available, otherwise fetched client-side via
SearchService.fetchListings. By default the client fetch filters by the URL’s
address parts (state/area/city/neighborhood); tenants with
searchListingsByLocationId: true filter by the tree-resolved locationId instead
(see below).
Configuration
| Config | Drives |
|---|---|
@configs/location | source (per tenant), stateFilter (per-board state= query format), useStateCodeRoute (URL shape), showAreas (area level on/off), cityPositionAreas (areas addressed without the -area marker), searchListingsByLocationId (listing geo-filter), cityTypes / neighborhoodTypes (location types the generator fetches as each level), hoodsByArea (neighbourhoods hang under their area’s city by address.area), areaCities (listing address.area → tree city), activeCounts (what the generator counts per location), maxNearbies / nearbyRadius, and the SEO/pagination thresholds. |
@configs/search | pageSize for the listing grid. |
@configs/map | animateLocationTransition — animate the header map camera between locations (false snaps instantly). |
@configs/features | locations gate. |
Gotchas & hints
-
Never build the tree at runtime. The location tree comes from a pre-generated
public/<tenant>/locations.json. Regenerate withpnpm generate:locations <tenant>after data or config changes — don’t compute it in a request. -
sourceis per tenant, and the only source setting.@configs/locationsource(MLS,LiveBy,UserDefined) is sent on every/locationsrequest — the app’s and the generator’s — and on autosuggest, and echoed back on each location. AlocationIdlookup goes without it: ids are namespaced by source and resolve across all of them. Every non-default tenant must set it. -
LiveBy New York takes two flags. LiveBy files the five boroughs as
city-alternateand postal cities ascity, and marks most neighbourhoodsaddress.city“New York” in every borough. SERHANT keepscityTypes: ['city-alternate']and setshoodsByArea, so the tree is borough → neighbourhood;areaCitiesmaps the county REBNY writes in a listing’saddress.area(Kings) back to its borough for the listing breadcrumbs and the dashboard. -
A neighbourhood outside the tree still gets its listings. With no tree node to take a
locationIdfrom,LocationsPageContentqueries by address strings; a city inareaCitiesgoes out as itsarea, so/ny/manhattan/midtownlists the 224 listings REBNY labels “Midtown” (LiveBy has only Midtown East/West/South). No polygon on its map. -
The cache is also a server-side allowlist.
locations.jsonis generated withhideTrash, so it contains every location that had listings and none with a zero count.loadCountsMap(LocationsTree/static.ts) exposes it as a memoizedlocationId → activeCountmap, and/api/overlay-locationsuses it to drop the empty neighborhoods that dirty MLS data returns for map overlays — see Map Overlays. The map is read server-side only: counts never ship to the client. Anything absent from the cache is invisible there until the nextpnpm generate:locations <tenant>. -
The generator drops every location it counts 0. By default it counts the listings listed in the last 90 days, active or sold. On a board new to Repliers whose active stock is older (REBNY), neighbourhoods holding only such listings came out 0 and vanished —
activeCountscounts every active listing instead. -
A tenant polygon clips the tree. The tree itself is fetched by a 4000 km radius around the tenant centre, so the only geographic bound is
@configs/mapsearchArea.boundary— the same polygonconstrainToSearchBoundaryclips listing search to. When it is set, the generator drops every node outside it (logged asboundary clip: dropped N), which keeps the catalog and the searchable area on the same geography; tenants without a polygon keep everything the board returns. -
Tree nodes carry a centre point, never polygons.
map.latitude/map.longitudeare cached per node, so nearby locations are computed locally — a pass over the tree withcalculateDistance, bounded bynearbyRadius, no request. Neighbours cross city lines and each carries the city that owns it, which is what builds its link. Polygons stay out of the file: a page fetches the current location’s boundary and one batch of child boundaries for hover highlighting. -
useStateCodeRoutechanges the URL shape:true→/tx/austin,false→/locations/austin. Middleware and URL builders both read it. -
An area can be addressed like a city. A board may file a place as an area whose children are cities — TRREB does that with Toronto over North York, Scarborough, Etobicoke, Old York and East York, and no city carries the name. Two mechanisms cover it, and they compose:
resolveLocationanswers a lone/on/torontofrom the area whenever the city position names one and no city does. Needs no config; it is skipped on tenants withshowAreas: false, where the area level does not exist at all, and on a URL that also names a neighbourhood.cityPositionAreas(@configs/location) lists the areas whose URL drops the-areamarker entirely, which is the one thing the parser cannot derive — it has no tree. That is what lets a city and a neighbourhood follow:/on/toronto/north-york,/on/toronto/north-york/bathurst-manor. List only a name no city shares, or that city’s page becomes unreachable.
Both URLs render either way; the short form is canonical (
getAreaUrl), so/on/toronto-areapoints at/on/toronto, and the sitemap publishes the short one. -
statevsstateCodevsstateFilter— three separate fields, never interchange them.stateis the full name for display/SEO ("Ontario"),stateCodethe 2-letter URL prefix ("on"→/on/toronto), andstateFilterthe value sent as the Repliersstate=query filter. They exist separately because Repliers stores the state per board in different formats: some boards return the full name (board 2 TRREB →"Ontario", 18 →"Alberta", 71 →"Connecticut"), others the 2-letter code (boards 68 →"MA", 90/91 →"ON", 149 →"WA"). Sending the wrong format returns zero listings and zeroes the location overlay.stateFilteris verified per tenant by querying that tenant’s board and reading a listing’saddress.state, and is used only in the four query spots (LocationsPageContent,_utils/parsers,LocationsTree/fetchers×2) — never for display or URLs. -
SEO thresholds filter the tree:
areaThreshold,minSeoCityCount,minSeoHoodCount, and themaxSeo*caps decide which locations render and how many are listed — low-count areas are dropped. -
searchListingsByLocationId(per tenant) picks the listing geo-filter. Off by default (query bystate/area/city/neighborhoodstrings, which the API expands into the fullpropertyTypelist). On (e.g.movesmartly-com) the client fetch sends the tree-resolvedlocation.locationId— a precise filter. The id is found by matching the URL’s SEO names against the cached tree infetchLocationsData, so no extra request is made. The default map rectangle fromgetBaseFilters(whole tenant region) ANDs harmlessly with the id. -
animateLocationTransition(per tenant) only toggles the header-map animation, not the camera logic. Defaulttruekeeps theflyTo/fitBoundstween inLocationMap.applyPosition;falsepassesanimate: falseso the map snaps to the exact same destination instantly (no tenant disables it today). It threads through the sharedfitBoundsutil’sanimateoption. All three camera branches move at a fastspeed: 2.4(2× the Mapbox default) —fitBoundsflies internally, so thespeedapplies to boundary transitions too, not justflyTo. -
The location’s polygon renders filled; hovering a child replaces it.
LocationMapdraws one GL polygon (draw-polygon): the page’s location filled in the standard boundary style, swapped for the hovered child’s polygon while a link is hovered and restored on blur (providerboundarystate). Drawing lives in its own effect, decoupled fromapplyPosition(camera only). -
Never re-apply the same style with
setStyleon mount. The map is constructed with its style already; callingsetStyle(sameStyle)in the[style]effect diff-reloads and wipes all custom GL sources/layers (firesstyledata, notstyle.load, so nothing re-adds them). AstyleAppliedref skips the first run so the location outline survives mount. -
A genuine style switch also wipes GL layers — restore in a
style.loadlistener, not an effect. An effect keyed onstyleraces the asyncsetStyle: it adds into the OLD style (still loaded while the new one fetches), and the swap erases it.LocationMapre-draws via a persistentmap.on('style.load', …)+addBoundaryPolygon. Same pattern asuse3DBuildings. -
URL slugs are classified location-vs-filters by vocabulary — token boundaries matter.
filter()in_utils/parsers.tsdecides whether/on/<segment>is a city or a filters segment. Bare vocabulary words match only whole tokens ('land'≠landsdale), mid-segment matching is limited to structural tokens (for,under,bedrooms…, orbusiness-parkhoods break), and ambiguousnew-*filters are a closed exact list inexactFilters(new,new-listings,new-construction) becausenewmarket/new-toronto/new-tecumsethare real city slugs. Regression cases live inparsers.test.ts. -
Location links navigate as plain anchors.
LocationLink,GroupTemplateand the sharedBreadcrumbsrendercomponent="a"(overriding the global next/linkLinkBehavior), so city/hood/breadcrumb clicks are full server navigations, not client transitions. -
A name can resolve to several tree nodes.
findCityByNamepicks the node with the highestactiveCount— deterministic, not tree order. Two kinds of collision exist: duplicate branches (samelocationIdtwice — a generation artifact, e.g. TRREB “Toronto”) and genuine cross-area collisions (different ids, e.g. TRREB “Ashton” Ottawa vs Lanark, URBN “Ashford” Pierce vs Lewis). Neighborhood-level collisions don’t occur in current trees.
Workflow and verification
Source review: e30dd9b47, 2026-11-02. The cross-layer guide covers generation, loading and rendering. Location pipeline tests ran. Missing files return an empty tree, malformed JSON can throw, and the process-lifetime count memo does not refresh just because a file changed.