Fallback
Delegates calls to a Primary provider, then falls back Secondary provider when an error is returned or the tile is outside the valid zoom or bounds.
Description
This provider is useful, for example, where you’re integrating with a system that returns an error for requests outside of the coverage area and you want to return a Static image in those cases without it being logged as an error. It especially can be useful in conjunction with the Blend provider or other providers that work on multiple children.
| The fallback provider is not meant to be used to handle auth errors with custom providers. The preAuth method is never called for the secondary provider and, if the primary provider returns an auth error, the secondary provider will not be called (the re-auth behaviour for the primary provider will occur as normal). Any auth error handling should be built into your custom provider itself. |
The bounds parameter is only applied at a per-tile level. That is, the edge where the fallback begins to kick in will visibly change as you zoom in/out. This allows this provider to work in a format agnostic manner for both raster and vector tiles. See the Crop provider to allow raster tiles to be limited at an exact geographic area.
Example
-
YAML
-
JSON
provider:
name: fallback
cache: always
zoom: 4-21
bounds:
south: 51
north: 63
west: -7
east: 0.1
primary:
name: proxy
url: https://tile.openstreetmap.org/{z}/{x}/{y}.png
secondary:
name: static
color: "0000"
{
"provider": {
"name": "fallback",
"cache": "always",
"zoom": "4-21",
"bounds": {
"south": 51,
"north": 63,
"west": -7,
"east": 0.1
},
"primary": {
"name": "proxy",
"url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
},
"secondary": {
"name": "static",
"color": "0000"
}
}
}
Configuration
| Parameter | Description | Type | Required | Default |
|---|---|---|---|---|
|
The provider to delegate to first |
Provider |
Yes |
None |
|
The provider to delegate to if primary returns an error |
Provider |
Yes |
None |
|
Zooming below or above this range will activate the fallback. Can be a single number, a range with a dash between start and end, or a comma separated list of the first two options. For example "4" "2-3" or "2,3-4" |
String |
No |
0-21 |
|
Any tiles that don’t intersect with this bounds will activate the fallback |
Object with north, south, east, west |
No |
Whole world |
|
When to save the resulting tile to the cache. Options: always, unless-error, unless-fallback. |
string |
No |
unless-error |