Module: ol/source/WMTS





optionsFromCapabilities(wmtsCap, config){Options | null}

import {optionsFromCapabilities} from 'ol/source/WMTS';

Generate source options from a capabilities object.

Name Type Description
wmtsCap Object

An object representing the capabilities document.

config Object

Configuration properties for the layer. Defaults for the layer will apply if not provided.

Required config properties:

  • layer - {string} The layer identifier.

Optional config properties:

  • matrixSet - {string} The matrix set identifier, required if there is more than one matrix set in the layer capabilities.
  • projection - {string} The desired CRS when no matrixSet is specified. eg: "EPSG:3857". If the desired projection is not available, an error is thrown.
  • requestEncoding - {string} url encoding format for the layer. Default is the first tile url format found in the GetCapabilities response.
  • style - {string} The name of the style
  • format - {string} Image format for the layer. Default is the first format returned in the GetCapabilities response.
  • crossOrigin - {string|null|undefined} Cross origin. Default is undefined.
WMTS source options object or null if the layer was not found.

Type Definitions


Name Type Argument Default Description
attributions AttributionLike <optional>


attributionsCollapsible boolean <optional>

Attributions are collapsible.

cacheSize number <optional>

Initial tile cache size. Will auto-grow to hold at least the number of tiles in the viewport.

crossOrigin null | string <optional>

The crossOrigin attribute for loaded images. Note that you must provide a crossOrigin value if you want to access pixel data with the Canvas renderer. See for more detail.

interpolate boolean <optional>

Use interpolated values when resampling. By default, linear interpolation is used when resampling. Set to false to use the nearest neighbor instead.

tileGrid WMTSTileGrid

Tile grid.

projection ProjectionLike <optional>

Projection. Default is the view projection.

reprojectionErrorThreshold number <optional>

Maximum allowed reprojection error (in pixels). Higher values can increase reprojection performance, but decrease precision.

requestEncoding RequestEncoding <optional>

Request encoding.

layer string

Layer name as advertised in the WMTS capabilities.

style string

Style name as advertised in the WMTS capabilities.

tileClass Class<ImageTile> <optional>

Class used to instantiate image tiles. Default is ImageTile.

tilePixelRatio number <optional>

The pixel ratio used by the tile service. For example, if the tile service advertizes 256px by 256px tiles but actually sends 512px by 512px images (for retina/hidpi devices) then tilePixelRatio should be set to 2.

format string <optional>

Image format. Only used when requestEncoding is 'KVP'.

version string <optional>

WMTS version.

matrixSet string

Matrix set.

dimensions Object <optional>

Additional "dimensions" for tile requests. This is an object with properties named like the advertised WMTS dimensions.

url string <optional>

A URL for the service. For the RESTful request encoding, this is a URL template. For KVP encoding, it is normal URL. A {?-?} template pattern, for example subdomain{a-f}, may be used instead of defining each one separately in the urls option.

tileLoadFunction LoadFunction <optional>

Optional function to load a tile given a URL. The default is

function(imageTile, src) {
  imageTile.getImage().src = src;
urls Array.<string> <optional>

An array of URLs. Requests will be distributed among the URLs in this array.

wrapX boolean <optional>

Whether to wrap the world horizontally.

transition number <optional>

Duration of the opacity transition for rendering. To disable the opacity transition, pass transition: 0.

zDirection number | NearestDirectionFunction <optional>

Choose whether to use tiles with a higher or lower zoom level when between integer zoom levels. See getZForResolution.

RequestEncoding{'KVP'} {'REST'}

Request encoding. One of 'KVP', 'REST'.