Services
Everything the ui may use from outside itself. The composition root builds one of these from real adapters (or fakes, in tests) and provides it through React context. Components never import an adapter, and reach a browser service only through a port.
This is an interface exported by @mapcairn/core, checked against version 0.2.0.
Signature
import type { Services } from "@mapcairn/core";
interface Services
Properties
basemaps
readonly basemaps?: BasemapCatalogue;
The basemaps the host offers, with their default. Optional: without it the ui offers the built-in basemaps. A host adds a provider whose terms it, and not the SDK, accepts by building a catalogue that includes it.
clipboard
readonly clipboard: ClipboardPort;
Copies text, such as a link.
createMapAdapter
readonly createMapAdapter: MapAdapterFactory;
Makes the map adapter the map view mounts.
featureQuery
readonly featureQuery?: FeatureQuery;
Finds the features inside a drawn shape, for the host that offers
selection by shape. Optional: a host that supplies none offers no such
action, and the ui must not require it. The reference host's
createServices() builds none.
fileOpener
readonly fileOpener?: FileOpener;
Asks the person for a file, such as shapes to import, and reads it in the browser. Optional: a host that supplies none gets no import, and the ui must not require it.
fileSaver
readonly fileSaver: FileSaver;
Offers a file the ui built, such as exported shapes, as a download.
languages
readonly languages?: LanguageCatalogue;
The languages the host offers, with the default and a loader for each.
Optional: without it the ui speaks only messages, follows no language
setting and shows no language switcher. The reference host offers one
language until it ships a translation.
layers
readonly layers: LayerCatalogue;
The data layers on offer, and whether they have loaded. A host with fixed
layers supplies a static catalogue, one that loads them supplies a
runtime catalogue, and one with none supplies emptyLayerCatalogue.
layerSource
readonly layerSource: LayerSource;
Loads any feed layer's features and details, reading everything from its definition.
location
readonly location: LocationProvider;
Finds the device's position.
messages
readonly messages: MessageCatalogue;
Formats every piece of user-facing text for the active language.
preferences
readonly preferences: DevicePreferences;
Reports the device's preferences, such as reduced motion.
routing
readonly routing?: RoutingProvider;
Finds routes and travel-time areas. Optional: MapCairn ships no provider, so a host that supplies none gets no routing, and the ui must not require it.
search
readonly search: SearchProvider;
Finds places by name.
selection
readonly selection?: FeatureSelection;
The set of features the person has selected, kept wherever the host
likes. Optional: a host that supplies none offers no selection, and the
ui must not require it. The reference host's createServices() builds
none, so the host that wants selection supplies a store.
settings
readonly settings: SettingsStore;
Remembers settings between visits.
suggestions
readonly suggestions?: SuggestionProvider;
Suggests places while the person types. Optional: a host that supplies none gets no suggestions and keeps submit-only search, and the ui must not require it. Everything typed is sent to the provider, so the host's privacy text must say so.
theme
readonly theme: ThemeSource;
Reads the system colour scheme and applies the theme shown.
url
readonly url: UrlState;
Reads and writes the shareable state in the address.