# RoutingProvider

Finds routes and travel-time areas. Implementations reject with a
`RoutingError` (`network`, `invalid`, `no-route`, `rate-limited`,
`unsupported`, or `aborted` when the signal fires first). The ui treats
`aborted` as "ignore this result".

This is an interface exported by `@mapcairn/sdk/browser`, checked against version 0.2.0.

## Signature

```ts
import type { RoutingProvider } from "@mapcairn/sdk/browser";
 
interface RoutingProvider
```

## Description

MapCairn ships no provider. A host supplies one for the service it chooses,
and lists on its privacy page what the provider sends: the stops or the
origin, and the mode. A service's own usage limits belong to its
implementation, since every caller shares them. The service is optional:
a host that supplies none gets no routing, and the ui must cope.

## Properties

### credits

```ts
readonly credits?: readonly RoutingCredit[];
```

The credits the map lists while a route or area from this provider is
drawn. Read each time the credits are drawn. Leave it out when the host
lists them itself or the service asks for none. In releases after
`0.2.0`, the interface `<mapcairn-map>` draws reads it; an app that lays
out its own `Attribution` passes the credits there.

## Methods

### reachableArea

```ts
reachableArea(request: ReachableAreaRequest): Promise<ReachableAreaResult>;
```

Finds the area reachable from `origin` within `minutes`. Rejects with
`invalid` for a position that is not on the globe or minutes that are
not greater than zero, `no-route` when nothing is reachable, and
`unsupported` for a mode the provider does not offer.

- `request` (`ReachableAreaRequest`)

### route

```ts
route(request: RouteRequest): Promise<RouteResult>;
```

Finds the route through `stops` in order. Rejects with `invalid` for
fewer than two stops or a position that is not on the globe, `no-route`
when no route links the stops, and `unsupported` for a mode the provider
does not offer.

- `request` (`RouteRequest`)

## See also

- [`RoutingCredit`](https://docs.mapcairn.com/api/sdk/browser/RoutingCredit.md)
- [`ReachableAreaRequest`](https://docs.mapcairn.com/api/sdk/browser/ReachableAreaRequest.md)
- [`ReachableAreaResult`](https://docs.mapcairn.com/api/sdk/browser/ReachableAreaResult.md)
- [`RouteRequest`](https://docs.mapcairn.com/api/sdk/browser/RouteRequest.md)
- [`RouteResult`](https://docs.mapcairn.com/api/sdk/browser/RouteResult.md)
