Skip to content

Commit

Permalink
Move BaseTileLayer to geo-layers (#4232)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Feb 5, 2020
1 parent af5e949 commit efe8c59
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 372 deletions.
130 changes: 0 additions & 130 deletions docs/layers/base-tile-layer.md

This file was deleted.

100 changes: 90 additions & 10 deletions docs/layers/tile-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,112 @@ new deck.TileLayer({});

## Properties

It implements geospatial-specific `tileToBoundingBox` and `getTileIndices` functions as props and also inherits all other [BaseTileLayer](/docs/api-reference/base-tile-layer.md) properties
### Data Options

### Render Options

##### `getTileData` (Function, optional)
##### `getTileData` (Function)

`getTileData` given x, y, z indices of the tile, returns the tile data or a Promise that resolves to the tile data.

- Default: `getTileData: ({x, y, z}) => Promise.resolve(null)`
- Default: `tile => Promise.resolve(null)`

The `tile` argument contains the following fields:

- `x` (Number) - x index of the tile
- `y` (Number) - y index of the tile
- `z` (Number) - z index of the tile
- `bbox` (Object) - bounding box of the tile, see `tileToBoundingBox`.

By default, the `TileLayer` loads tiles defined by [the OSM tile index](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames). You may override this by implementing `getTileIndices`.


##### `maxZoom` (Number|Null, optional)

Use tiles from this level when over-zoomed.

- Default: `null`


##### `minZoom` (Number, optional)

Hide tiles when under-zoomed.

- Default: 0


##### `maxCacheSize` (Number|Null, optional)

The maximum cache size for a tile layer. If not defined, it is calculated using the number of tiles in the current viewport times multiplied by `5`.

- Default: `null`


##### `strategy` (Enum, optional)

How the tile layer determines the visibility of tiles. One of the following:

* `'best-available'`: If a tile in the current viewport is waiting for its data to load, use cached content from the closest zoom level to fill the empty space. This approach minimizes the visual flashing due to missing content.
* `'no-overlap'`: Avoid showing overlapping tiles when backfilling with cached content. This is usually favorable when tiles do not have opaque backgrounds.

- Default: `'best-available'`


##### `tileToBoundingBox` (Function, optional)

**Advanced** Converts from `x, y, z` tile indices to a bounding box in the global coordinates. The default implementation converts an OSM tile index to `{west: <longitude>, north: <latitude>, east: <longitude>, south: <latitude>}`.

Receives arguments:

- `x` (Number)
- `y` (Number)
- `z` (Number)

The returned value will be available via `tile.bbox`.


##### `getTileIndices` (Function, optional)

**Advanced** This function converts a given viewport to the indices needed to fetch tiles contained in the viewport. The default implementation returns visible tiles defined by [the OSM tile index](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames).

Receives arguments:

- `x` (Number) - X of [the OSM tile index](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames)
- `y` (Number) - Y of [the OSM tile index](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames)
- `z` (Number) - Z of [the OSM tile index](https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames)
- `bbox` (Object) - bounding box of the tile, in the shape of `{west, north, east, south}`.
- `viewport` (Viewport)
- `minZoom` (Number) The minimum zoom level
- `maxZoom` (Number) The maximum zoom level

Returns:

An array of objects in the shape of `{x, y, z}`.


### Render Options

##### `renderSubLayers` (Function, optional))

Renders one or an array of Layer instances with all the `TileLayer` props and the following props:

* `id`: An unique id for this sublayer
* `data`: Resolved from `getTileData`
* `tile`: An object containing tile index `x`, `y`, `z`, and `bbox` of the tile. `bbox` is an object of `{west, north, east, south}`.
* `tile`: An object containing tile index `x`, `y`, `z`, and `bbox` of the tile.

- Default: `props => new GeoJsonLayer(props)`


### Callbacks

##### `onViewportLoad` (Function, optional)

`onViewportLoad` is a function that is called when all tiles in the current viewport are loaded. The loaded content (as returned by `getTileData`) for each visible tile is passed as an array to this callback function.

- Default: `data => null`


##### `onTileError` (Function, optional)

`onTileError` called when a tile failed to load.

- Default: `console.error`


# Source

[modules/geo-layers/src/tile-layer](https://github.com/uber/deck.gl/tree/master/modules/geo-layers/src/tile-layer)

0 comments on commit efe8c59

Please sign in to comment.