Data layers
Part of Architecture, which is built from ARCHITECTURE.md in the repository, where it is edited.
How data layers are defined, loaded and shown on the map.
A data layer is typed data: a LayerDefinition in packages/web/src/layers/definitions/, one file each, collected with import.meta.glob. Nothing in the code branches on a layer id, a provider or a response shape.
A layer's path from file to map, for a feed layer, with arrows in the order things happen. createServices() passes the catalogue and FetchLayerSource to the ui. A tile or vector layer has no load step: MapDataLayers hands the adapter its source, and the engine requests the tiles.
- Core (
packages/core/src/layers) holds the definition types and a hand-written schema check (validateLayerDefinition; core stays free of schema libraries), URL and card templates ({window},{time|relative}; a tile URL leaves the engine's{z},{x},{y}and{bbox-epsg-3857}alone, while an identify URL fills{x}and{y}itself), host-keyed card, list, feed-shape label and unit templates (LayerTemplate), derived URL variables looked up from control values, filters, a decoder registry with the built-ingeojsondecoder (fields mapped by dotted path, so USGS and GDACS share it), a formatter registry (relative,number,km,date), style evaluation with a legend derived from the style, palette slot names, andSharedResponseCache, which reuses a response for itsmax-age(or the definition'scacheSeconds) and shares a request in flight, so layers split from one feed cost one request. It also holds theLayerCatalogueimplementations andpartitionDefinitions(see "Ports"). - The
LayerSourceport loads any feed definition withload({ definition, controls, now, signal })and an on-requestloadDetail, and rejects only with a typedLayerError(network,invalid,empty,aborted). A detail URL comes from the provider's data, so it is requested only when it ishttpson an origin the definition declares. Its third method,identify({ definition, controls, now, at, signal }), asks what a tile layer'sidentifyblock says is at a tap and is required, so a host's ownLayerSourcemust implement it. Nothing found resolves to an empty list, neverempty; it rejects withnetwork(which includes any error status, 401 and 403 too until anunauthorisedkind exists),invalid(a URL that cannot be built or is nothttps, which core'sidentifyRequestUrlchecks for every source, or an answer that is not a document the decoder reads) oraborted. The size of an answer belongs to the source: one that reads from a network applies a limit of its own to every answer and refuses a larger one asinvalid, so the contract suite requires it.FetchLayerSourcereads at mostMAX_IDENTIFY_RESPONSE_BYTES(1 MiB) of an identify answer and at mostmaxResponseBytesof a feed, query or detail answer, checked againstContent-Lengthand again while reading, which stops and cancels the stream at the first chunk over the line.maxResponseBytesis an option of the source (FetchLayerSourceOptions), not of a definition, so it is the same for every layer the source serves: one large layer raises it for all of them. It defaults toDEFAULT_MAX_RESPONSE_BYTES(4 MiB, inFetchLayerSource.ts), a limit the recorded fixtures are far below (they are trimmed samples, so no test ties the limit to a real feed), and a test inlayers.test.tsrequires it to be at least four times the largest size any detail source'sdataCoststates. An over-limit answer is not kept in the response cache, and the layer shows the same error state and message as any otherinvalidanswer. The identify path sends the request through the same private fetch-and-parse method as every other request, but never throughSharedResponseCache: a tap's URL never repeats, and a kept answer would push feed responses out of the cache, so it ignoresCache-Controland shares no request in flight.FakeLayerSourcescripts identify apart from load (setIdentified,failIdentify,holdIdentify(layerId)for one layer, andidentifyRequestswith the URL a real source would fetch) and applies no size limit to an identify answer.setOversizeAnswer(layerId, kind)makes a layer's feed or detail answer larger than the source's limit, so it refuses it asinvalid, and a host can script "features load, detail refused". TheLayerSourcecontract suite covers identify with two layers,CONTRACT_IDENTIFY_LAYERandCONTRACT_OTHER_IDENTIFY_LAYER, andLayerSourceControlshas four required members beyond the feed ones:respondToIdentifyWith,failIdentifyWithandholdIdentifyfor identify, andrespondWithOversizeAnswer(kind)for the size limit (the subject makes its source answer a feed or a detail with a body larger than whatever limit it applies, and the suite requires the read to fail asinvalidand an answer within the limit to load), so a host that runs the contract against its own source must supply them.useDataLayers.identifyAtcalls it (see "Identify at a tap" below); the reference site's layers have noidentifyblock, so nothing asks it there. - Map (
packages/map/src/layers) hasuseDataLayers(state, loading, cancellation, announcements, the permalink value),MapDataLayers(draws through the adapter, turns taps into open cards),SelectionMarker, and the genericLayersSection, card and list. "Show on map" inLayersSectionfits a polygon or line withfitPadding, clear of the sheet (at its half detent) or the side panel, the search pill and the end stack, and above the map key while it shows:MapChromepublishes how far up from the bottom edge the key reaches (mapKeyClearancein the chrome layout context), and the fit keeps clear of it where that still leaves twiceREVEAL_CLEARANCEof map. A point is centred in what the sheet or panel leaves free. The data palette values live in@mapcairn/theme(tokenValues.dataPalette).- How
useDataLayersloads. Its load effect is four small steps, each a pure function beside the hook.wantedLoads(loadRequests.ts) resolves what each enabled layer asks for, as a request key and, for a query layer, a window.planLoadsdecides what to cancel, forget and start by comparing those keys with the requests in flight and settled.loadOutcome(loadOutcome.ts) loads one request through theLayerSourceand works out what the layer then shows and says, andreportLoadandreportZoomLimits(loadReport.ts) say it, once for a query layer. A render writes no ref: the window a query layer chose is remembered, and the committed state the handlers read is kept, in effects, so a render React throws away (a transition that suspends) leaves nothing behind. - Turning layers off at once.
useDataLayers.turnOff(ids, { group })turns several layers off in one state change, so the engine is drawn once and the address changes once, and announces once ("3 layers turned off. Undo available"). It clears each layer's results, selection, choices, tiles known to have failed and affected area exactly assetEnabled(id, false)does (both usewithoutTraces), and the load plan cancels the layers' open requests. It records the ids as an undo offer:turnedOffreports how many of them are still off and in the catalogue (null when none is, so the offer never claims more than is true), andundoTurnOff()turns those back on in one change and announces once. A layer keeps its control values while it is off, so Undo needs no snapshot of them. The offer is state, not a ui timer: it lapses afterUNDO_TIMEOUT_MS(10 seconds), is replaced by the next batch, and does nothing once gone, so a closed and reopened sheet never shows a stale one.holdUndo(by)andreleaseUndo(by)pause the countdown for a holder (pointerorfocus), and it restarts in full once neither holds. Other changes the person makes meanwhile do not cancel the offer. There is no batch that turns layers on. - A catalogue that loads or changes.
useDataLayerskeeps the layers a link names (itsinitialoption) as a waiting list, apart from the layers that are on. A catalogue that isreadyat mount, as the static one is, resolves the list at once, and an id it does not have is dropped without a word, so the reference site behaves as before. While the catalogue isloadingor hasfailedthere are no layers, so the ids wait andurlValuekeeps them, with the link's control values as written.useViewPersistencewrites whateverurlValueholds on each settled view and each change to it, so the address keeps them. A link carries at most 20 layers (parseUrlHash) and nothing can be turned on while there are no layers, so the waiting ids stay within that; the readable ids past the 20 arrive asLayersUrlState.dropped, which the hook keeps beside the waiting ids (Link.dropped) until the first list. When a list arrives, each waiting id it has is turned on with its control values resolved against the definition, and each it has not (missing, or not offered to this person) is dropped for good: a later refresh that lists it does not turn it on. Only a catalogue that was notreadyat mount says so, once. Every state the catalogue publishes is taken in during the render that sees it, and areadylist with a change goes through the purereconcile(catalogueReconcile.ts), so no render holds a layer without its controls.reconcilecounts the waiting ids the list lacks together withLink.droppedaslinkMissing, and returns the link emptied, so the count is said once;urlValueis built from the ids and values only, so the count never reaches the address. It also reports the ids the list added and removed, which feed the "Layers updated" message; the skipped count comes from the catalogue's own state. A layer that arrives gets its controls' defaults, a layer whose definition object changed keeps the control values that are still valid and takes the default for the rest, and one whose definition is the same object keeps its values as they are. An enabled layer that is no longer listed is turned off assetEnabled(id, false)turns it off: the load plan aborts its request, and its results, selection, choices and affected area are cleared. It also leaves the address. A layer removed from the list, on or off, leaves any Undo offer as well, so Undo never turns on a layer that was removed and listed again. What a transition says aloud is worked out by the purecatalogueNotice(catalogueNotice.ts), kept in the state and spoken once from an effect, so a render that React repeats says nothing, and each state is said once, when it is entered. A new list is one polite message fromannounceCatalogueChange(core), in a fixed order: the layers turned off ("Rainfall is no longer available and was turned off." for one layer, "2 layers are no longer available and were turned off." for several), the layers of the link that are not available ("1 layer in the link is not available.", for a catalogue that wasawaited), the definitions that could not be shown ("1 layer could not be shown.", said each time the count changes to a number above zero, the first list included), what a refresh added and removed ("Layers updated: 1 added, 1 removed.", with a part that is zero left out, and only for a list that follows one already shown), and "No layers are available." when the first list of anawaitedcatalogue is empty. Two states are separate messages: "Loading layers", polite, said only while a layer named by the link is waiting, and a failed load ("Layers could not be loaded.") or a failed refresh ("Layers could not be updated. Showing the last list."), assertive. The announcer coalesces messages that arrive within its window (THROTTLE_MS, 600 ms) to the latest of them, except kept ones, which queue behind each other in order, and the same words twice withinDEDUPE_MSare said once. Every catalogue message but "Loading layers" is sent with the announcer'skeepoption, because each is the outcome of a discrete change (a list arriving, a load or refresh failing), so a later message, such as the load result of a link layer, queues behind it and does not replace it (#111, fixed by #144). "Loading layers" is not kept: it is a state, not an outcome, and a later message may replace it. - A replaced definition is drawn again. For each map id,
MapDataLayersremembers what it last handed to the adapter, which includes the definition object, compared by identity (DrawninMapDataLayers.tsx). A layer is drawn again through the same adapter method as before (setFeatureLayerorsetStyledShapesfor a feed,setHeatmapLayer,setVectorLayerwith asetHeatmapLayerfor each heatmap source layer, orsetTileLayer) when its definition is another object, as well as for the changes that already redrew it: a feed's or heatmap's features, the control values of a heatmap or vector layer, and a raster layer's URL or opacity. So a refresh that changes only a style, a heatmap setting, a vector layer's zoom limits, a raster layer's tile size, zoom limit or bounds, or the colour of a shown affected area (its layer'sdetailblock) shows the change. A definition that is deeply equal to the earlier one keeps the earlier object (partitionDefinitions), so a refresh that changes nothing draws nothing, and a change of URL together with the definition draws once. A feed whose definition is replaced is drawn from the features it already has, and they are requested again only when its request URL changes or it is retried (loadRequests.ts), so a host puts a version in the URL when the data changes. The same holds for a change to how features are decoded (the decoder, the field map or the filter, applied inpackages/core/src/layers/feed.tswhen the response is read), including a style, label or list that now names a field the field map did not read: the features already loaded are not read again, so the change needs a new URL or a retry to take effect. A change to the style, label or list alone, over fields already read, shows at once. A load already in flight when the definition is replaced finishes with the old definition's decoder and is announced under it, becausestartLoadinuseDataLayers.tscaptures the definition and the request key does not change. Each draw method replaces what is under its id in one call, andMapDataLayersdraws every layer before it removes the ids it no longer draws, so a replaced layer is never removed first and does not flicker; what is left over, such as a heatmap source layer the new definition no longer has, is removed afterwards. The reference site's static catalogue never replaces a definition, so it draws as before.
- How
- Web registers the definitions and
FetchLayerSourceincreateServices(). A loop test (src/layers/layers.test.ts) checks every definition against the schema, the production CSP (a layer's feed, detail, tile and identify origins inconnect-src, and its tile origin inimg-src),ATTRIBUTIONS.mdand a recorded fixture, and names what is missing. - Layer kinds. A definition is one of five kinds, which decide what the ui offers:
points,shapes,heatmap,tilesorvector. The guardsisFeedLayer,loadsFeatures,isHeatmapLayer,isVectorTileLayerandisShapeStyletell them apart, and the ui reads those, not a kind name. A feed layer'sstyleis a point style (nokind) or ashapesstyle for polygons or lines: a colour rule (fixed,category,stepsfrom explicit class breaks, orintervals, equal classes over a numeric field worked out frommin,maxand the ramp's length), a pattern, dash and width per class, a fill opacity and a label template. Validation requires a second signal beside colour: a different pattern, width or dash in every class, or a label that names the field. Aheatmaplayer draws a feed or query as density with radius and intensity taken fromrangecontrols and an opacity control; its legend names each step of the ramp in words. Avector-tileslayer has a tile URL, a zoom window for the layer and for each source layer, and a style or heatmap per source layer; its colour rules and label read tile properties by name. Features of a vector tile layer stay in the tiles, so it has a key and no cards or list. Atileslayer may add anidentifyblock that names a URL, atolerance(a whole number of pixels from 1 to 20, default 12), a decoder, an optionalrecordspath,fieldsand acard. The card is nested, not on the layer, soisFeedLayerandloadsFeatures(which test for a top-levelcard) do not send the layer toload;isIdentifiable,hasCard(a feed layer or an identifiable one) andcardOf(a feed's card, oridentify.card) are how code asks. Core builds the request (identifyUrl: a square of2 * tolerance + 1pixels centred on the tap,{bbox}in EPSG:3857 metres and not clamped at the edges of the world,{width},{height},{x},{y},{lng},{lat}and{zoom}) and decodes the answer (decodeIdentify: GeoJSON, or a JSON list atrecords; a feature with no geometry is placed at the tap, nothing found is an empty list, and at most 20 features are kept). Validation (validateIdentify.ts) reports problems asidentify.url,identify.fields.idand so on, requires anhttpsURL whose scheme, host and port hold no placeholder, and refuses a control or derived variable named like one of those variables.LayerSource.identifyasks it (see "TheLayerSourceport" above) anduseDataLayers.identifyAtcalls it for a tap.LayerItemsays "Tap the map to see details for this layer." after the legend of an identifiable layer that is on, andLayersSectionsays "Only the first 4 layers are asked on one tap." once when more thanMAX_IDENTIFY_LAYERSidentifiable layers are on. The waiting line is described under "Identify at a tap". The guide is insites/docs/docs/guides/extending.md. - Shape template types.
ShapeStylekeeps its previous string-only label type by default, preserving vector-layer label assignment. Feed shapes that use host-keyed labels useFeedShapeStyle; vector-tile layers use the defaultShapeStyle, and validation keeps their labels to one raw property template. - Query layers. A
querysource asks only for the features in view. The URL uses{west},{south},{east}and{north}(and{limit}, one above the cap, so a response shows that more exist).MapDataLayersreports the view (useDataLayers.setView) when a query layer, or any layer whose definition has a zoom window (hasZoomWindow), is turned on and again after the map has been still for 400 ms.nextQueryWindowkeeps the last window while the view stays inside it and is not much smaller, and otherwise takes a new one snapped to a grid, so small pans send nothing and nearby views share a request. A provider takes a box inside -180 to 180, so the window is clamped there, except for a view across the antimeridian: its window is the short box (westinside -180 to 180,eastpast 180, asboundsOfPointsreturns) andqueryBoxessplits it into the part fromwestto 180 and the part from -180 to the rest.feedUrlthrows for a window across the line (it used to clamp it, which asked for the wrong area), andfeedUrlsgives one URL for each box anddecodeFeedsjoins the answers, keeping a feature both hold once (the same id and the same geometry), giving a different feature that shares an id a new one (a decoder's position for a feature with no id starts again in each response), and applyingmaxFeaturesto the whole;FetchLayerSourceand the fake both go through them, and if either request fails the other is stopped and the layer shows its error with no partial result, by design. Each half is capped atmaxFeaturesplus one by the provider, so a view across the line can fetch up to twice the data of one that does not. A view across the line therefore sends two requests instead of one, to the same provider and with the same values otherwise; every other view sends one as before. A window's request key is the URLs of its boxes, so it is one load. One load is in flight per layer: a new window cancels the old one. The layer keeps what it draws while the next window loads, draws at mostmaxFeaturesand says "Showing the first N. Zoom in to see more.", and below its ownminzoomasks for nothing and says "Zoom in to level 9 or closer to load this layer." (the level is the definition'sminzoom, a normalised zoom, so it needs no conversion). A vector tile layer outside its ownminzoomandmaxzoomsays the same, or "Zoom out below level 12 to see this layer.":layerZoomLimitin core reads the window from the definition, and the status is{ kind: "zoom-in" | "zoom-out", level }. A layer without a window says nothing about zoom. A query layer announces each state once, so a pan to another window is silent; a layer outside its window says so once, and again after it has been back inside. - The key.
legendFor(core) derives a layer's key from its definition.LayerKey(packages/map/src/layers) draws it, and both the Layers section andMapKeyuse it, so the two cannot drift.mapKeyBlocksturns the layers' state into the blocks of the map key (the layers that are on and have a key, in catalogue order, each with the day or time its controls say, fromdescribeChosenTime), as plain data for any drawing.MapKeyrenders them inMapChrome'smapKeyslot and holds only whether it is minimised, in memory; it requests and stores nothing. - Open card. The feature whose card is open is
useDataLayers'sselected, set byselect. A tap that finds several features callsuseDataLayers.choose(hits): one opens its card, several openFeatureChoices, a list of rows that each open a card, and the card offers "Back to list". TheIkey runs the same route from the centre of the map (featuresAt), and says when nothing is there. The open card keeps a snapshot of its feature, so a query layer's card survives a refresh for another part of the map. It is not the selected set below.FeatureCardandFeatureChoicesread the card template throughhasCardandcardOf, so a feature found by a tap on a tile layer opens the same card and row: with no style it has no glyph and no class line, and no "Show affected area".LayersSectionandfeatureTitledo the same. Identified features are not selectable, because their ids are not stable from one tap to the next, andselectableRefsonly admits a feed layer's. - Identify at a tap.
useDataLayers.identifyAt(target, { focus })(packages/map/src/layers/useDataLayers.ts, withidentifyRun.tsbeside it) asks every tile layer that is on, has anidentifyblock (isIdentifiable), that the map has not reportedtiles-unavailable(a layer reported slow is still asked, because it may be showing part of its imagery) and whoseboundshold the tapped place, at mostMAX_IDENTIFY_LAYERS(4) in catalogue order. The requests start together, and each hasIDENTIFY_TIMEOUT_MS(8 seconds), counted by the hook (IdentifyRun.ask), which records a timeout itself because a source only sees that its request was aborted. A request ends with the source's answer or with the abort, whichever comes first, so a source that is slow to notice an abort does not hold the tap up. The hook waits for all of them, changes its state once and says one message, then resolves with{ asked, found }, or with null when the tap was cancelled or replaced meanwhile, which opens and says nothing. When no layer can be asked it resolves at once withaskedof 0 and changes nothing, so the host can fall back to its own message ("No features at the centre of the map."). What a layer found sits in its own state slot,identified(by layer id, with the tile URL it was asked about), apart fromresults, which feeds the list and the drawing;featuresForreads one or the other forselectand theselectedandchoicesmemos, and the layer's ownfeaturesstay empty. An entry is replaced at settlement, not at the start, for each layer that answered, so a tap on empty ground leaves an open card alone, except a card that points into an entry that was replaced, which closes. A layer that failed keeps what it had. One feature opens its card, several openFeatureChoicesthroughwithOpened, the stepchooseuses for several features, and the caller then opens the sheet (useMapApp.openFeature). An entry is cleared bywithoutTraces(turning the layer off,turnOff, a layer leaving the catalogue) and when the layer's tile URL changes, astilesUnavailableis. A layer that answered before it was turned off, or before its tile URL changed, while another layer was still held, has its answer dropped at settlement (stillCurrent, which reads the committed state), so it neither opens nor is counted.- One message. Core's
announceIdentified(announce.ts) takes{ found, asked, available, failed }and returns the message and priority, or null. Several found: "3 features here. Choose one from the list." One found: nothing, because the card takes focus. None found: "Nothing found here." (not said when every layer failed). Layers that failed or timed out are named after it: "Rainfall did not answer.", "Rainfall and Wind did not answer." or "Rain, Flood and Wind did not answer.". When the cap held layers back it adds "Asked 4 of 6 layers.".askedcounts the layers that answered or failed, and a layer cancelled meanwhile (turned off, say) is in neitheraskednoravailable. The message is assertive only when every layer asked failed, and polite otherwise. The hook sends it once, at settlement, with the announcer'skeepoption, because it reports the outcome of the person's tap and a later message must not replace it;choosealso sends its "N features here" message withkeep, and the host's "No features at the centre of the map." does too.chooseis not used on this route, so it does not announce a second time.identifyingis true from the start of a tap until it settles or is cancelled; it is the status data for the "Looking up what is here" line.useIdentifyFeedback(identifying)(identifyFeedback.ts) turns it into a flag that is true only afterIDENTIFY_FEEDBACK_MS(400 ms), so an answer that comes sooner shows nothing, and false again as soon as the lookup ends, whether by its answer, a new tap on a drawn feature, a surface change or Escape.IdentifyStatusdraws the line, and the host puts it in the bottom-centre slot (AppChrome, above the banners). It is aStatusMessage(variantinfo), so the wait is said once, politely, by the line's own status region when the line appears at 400 ms, and the visible words and what a screen reader hears are the same, which keeps a person who pressesIfrom pressing it again and restarting the lookup. That is a different live region from the announcer's, so the result, whichuseDataLayerssays through the announcer withkeepwhen it arrives, never replaces the wait or is coalesced with it, whether the answer comes just after the line or much later, or the layers fail. A lookup that answers before 400 ms shows and says no wait, only its result. Escape and the line's dismiss button (onCancel, which hosts passlayers.cancelIdentify) end the lookup and say nothing more. The line's own countdown is longer thanIDENTIFY_TIMEOUT_MS, so only the lookup's timeout ends a lookup by itself. A second tap while a lookup waits keeps the line, as the lookup is still waiting, and does not restart its delay. - Cancelling. A new
identifyAtcancels the one in flight.cancelIdentify()aborts the requests and returns whether there was one in flight.select(when it opens a card) andchoose(when it opens one or a list) cancel it too, so a card opened by a tap on a drawn feature, theIkey or a list row is never replaced, nor has its focus taken, by a late answer.MapDataLayerscalls it whenignoreTapsturns true, anduseMapAppcalls it when the open surface changes, fromonLongPress, and first fromonEscape, which closes a surface only when nothing was in flight.onEscapeserves both Escape routes: the map region's (MapView'sonEscape) and the document-level listener inAppChrome, so one press ends a lookup wherever focus is. A layer that is turned off, leaves the catalogue or changes its tiles has its request aborted when the change commits (IdentifyRun.abortStale), and the other layers' answers still settle. Unmounting aborts every request. - The tap route.
featureTapfires only for drawn features, so the host'sonClickis the route:useMapApp.onMapClick, on the plain map (not Measure, Directions or Draw), callsidentifyAtwhenadapter.featuresAt(event.point)is empty, andidentifyAtCentredoes the same from the centre of the map, with its longitude wrapped to -180 up to 180 as a click's is, and says nothing until the layers answer. While Measure, Directions or Draw is open the key asks no raster layer, and says "No features at the centre of the map." when no drawn feature is there, as before. The reference site's layers have noidentifyblock, so none of this asks anything there. No host has select mode yet, so nothing stops a raster request while one is on: that gate belongs to plan 0007's select mode when it lands.
- One message. Core's
- The selected set.
useFeatureSelection(layers, { formatters })(packages/map/src/layers/useFeatureSelection.ts) holds the host'sFeatureSelectionstore as the ui shows it. The host calls it once, besideuseDataLayers, because its state outlives the sheet's sections, which unmount. It reads the store withuseSyncExternalStoreand returns null whenServices.selectionis absent.SelectionProviderhands the result down, anduseSelection()returns it, or undefined outside a provider or when the host has no store, so a component that selects or lists features renders nothing then and takes no prop for it. The reference host calls it inuseMapApp(packages/web/src/app/useMapApp.ts, which returns the result asapp.selection) andApp.tsxmountsSelectionProvideraroundMapView, and the example app does the same inExampleMap(examples/embed/src/ExampleApp.tsx). Each mounts the provider whether or not there is a store, because a provider given null provides nothing and a conditional wrapper would change the tree around the map.createServices()builds no store, so on the reference site the hook returns null, nothing reads the set and the site is unchanged; the example runs on theMemoryFeatureSelectionthatcreateFakeServicesbuilds (examples/embed/src/exampleServices.ts). No component readsuseSelection()yet.- Resolving.
resolveSelection(selectionResolve.ts) turns each reference into the feature its layer has loaded, else the snapshotreconcileSnapshotskept while it was loaded, but only while its layer is on andisFeedLayer. Otherwise it is "not shown": it stays in the store and counts. Turning a layer off drops nothing and announces nothing from the selection:useDataLayerssays the layers were turned off, and a selection change that follows within the announcer's window is a separate message, sent when the window ends (the turning-off message is kept, so a later selection message that is not kept queues behind it and is spoken when the window ends). Undo brings the references back. An entry holds the layer's definition, not its state, andresolveSelectiontakes the previous result and returns the same entries, and the same array, when nothing they show changed, so a map move, which makes new layer states with the same features, does not re-render what reads the selection.addignores a reference whose layer is not a feed layer in the list (selectableRefs). - A layer removed from the catalogue. Undo cannot bring such a layer back, so the hook drops its references. It keeps the ids of the last list the catalogue held while it was
ready(layers.catalogue.status, so a loading or failed state leaves them as they were). When a ready list lacks an id the last one had, it removes the references to that id with oneremovecall (refsOfRemovedLayersinselectionResolve.ts), which is one store change and one message with the new total, such as "2 features removed. 1 selected.". A layer that was off when it left is dropped the same way. Nothing is dropped at mount, while the catalogue is loading or has failed, when its first ready list arrives, for a layer no ready list ever held, or for a reference the store hydrates later, because none of these is a removal. A changed definition with the same id is not one either. - Messages.
toggle,add,removeandcleareach announce once throughLiveRegion, with the words in core'sannounce.tsand the choice inselectionMessages.ts. The message is worked out from the set before and after the call, because the store returns nothing: a batch the store refused for itslimitis told from a batch of duplicates by changing nothing while a reference was new. Each message carries the new total, because the announcer replaces a waiting message that is not kept with a later one when both arrive withinTHROTTLE_MSof the last one sent, so the one that is read is still true. The announcer'skeepoption, used for the outcome of a person's own action such as turning layers off or back on, exempts a message from that replacement; the selection's messages do not use it. A refusal past the limit is assertive, as a refused import is, so a later polite message cannot replace it; the others are polite. A change made outside the hook, such as hydration, updates the entries and is not announced. The select-mode flag is held in the hook and nothing reads it yet.featureTitle(featureTitle.ts) fills the card title template forFeatureChoicesand for the messages.
- Resolving.
- Controls. A definition's controls are
segmented,switch,date(a UTC day, bounded by fixed days or{ daysAgo }),datetime,opacityandrange. A range unit usesLayerTemplateand includes its own spacing. Adatetimecontrol is a UTC day and a time on a fixed step (stepMinutes, which divides a day), for a product the provider names by timestamp, such as the half-hourly rainfall. Its bounds are fixed slots or{ minutesAgo }, counted back fromnowand rounded down to the step, so amaxset to the provider's latency keeps times that are not out yet off the list. Validation refuses a backwards range (fixed or relative), a relativeminwith a fixedmax(it would pass it as time goes on) and a relative bound over about a hundred years (MAX_MINUTES_AGO), and a relative default is clamped to the bounds when it is worked out. Its value is the slot's start writtenYYYY-MM-DDtHHMM(link-safe), andtemplateValueshands a URL template the ISO instant instead (2026-11-11T14:30:00Z). Core getsnowfrom the ui's clock (useDataLayers.now): a layer's default slot is fixed when the layer first arrives (at mount for a static catalogue) and resolved again when a refresh replaces its definition, and the offered range and the newest slot shown are worked out again on each render, with no timer and no request of their own. The helpers are inlayers/dateTime.ts. - Permalink.
UrlStateValue.layersis written as#layers=earthquakes,imagery&earthquakes.window=day, together with the view, so neither drops the other. BothserialiseUrlHashandparseUrlHashkeep at most 20 layers (MAX_LAYERS), the first 20 in order, so an address the app writes is read back whole; a hand-edited link with more keeps its first 20 distinct readable ids andparseUrlHashcounts the rest inLayersUrlState.dropped(left out when zero, never written, and not counted for a repeated, unreadable or empty id, which is skipped as before). That count joins the layers of the link that are not available in the one note a catalogue that was notreadyat mount says (see "A catalogue that loads or changes"). Values are resolved against the definition when read, so a hand-edited link cannot reach an unknown control or value: a date or a date and time outside its bounds moves to the nearest bound, and a date and time between steps is rounded down to its slot. Layers the link names that a catalogue still loading has not listed stay in the address until its list arrives (see "A catalogue that loads or changes").