# useDataLayers

The state of every data layer and the actions on it, driven entirely by
the definitions in the catalogue: nothing here names a layer. It reads the
catalogue as a store, so the layers appear when a catalogue that loads
becomes ready; while it is loading or has failed there are none, and the
layers a link names wait for the first list. Each list that arrives is
reconciled with the choices in the same render, before anything is drawn
or requested: a layer that arrives has its controls' defaults, one that
changed keeps the values that are still valid, and an enabled one that went
is turned off as `setEnabled(id, false)` turns it off and said once.

This is a function exported by `@mapcairn/map`, checked against version 0.2.0.

## Signature

```ts
import { useDataLayers } from "@mapcairn/map";
 
function useDataLayers(options?: UseDataLayersOptions): DataLayers;
```

## Parameters

- `options?` (`UseDataLayersOptions`)

## Returns

`DataLayers`

## Remarks

Nothing is requested until a layer is turned on. A feed layer is
 loaded on enable, on a control change and on retry; the request for the
 previous URL is cancelled. Tile layers need no request here: the map
 draws their tiles, and says through `reportTilesSlow` when none has
 loaded for a long while, `reportTilesUnavailable` when the map settled
 with none loaded and `reportTilesRecovered` when one loads later. Loads,
 empty feeds and failures are announced once each through the shared live
 region, failures assertively and a tile layer that is slow or has no
 tiles, and its recovery, politely. Turning a layer off clears its features, its open card
 and its affected area.

## See also

- [`UseDataLayersOptions`](https://docs.mapcairn.com/api/map/UseDataLayersOptions.md)
- [`DataLayers`](https://docs.mapcairn.com/api/map/DataLayers.md)

Source: [packages/map/src/layers/useDataLayers.ts:798](https://github.com/MapCairn/mapcairn/blob/main/packages/map/src/layers/useDataLayers.ts#L798)
