Class: WMTS

ol/source/WMTS~WMTS


import WMTS from 'ol/source/WMTS.js';

来自 WMTS 服务器的瓦片数据图层数据源。

new WMTS(options)

Name Type Description
attributions AttributionLike | undefined

归属信息。

attributionsCollapsible boolean (defaults to true)

归属信息是否可折叠。

cacheSize number | undefined

已弃用。 请改用图层上的 cacheSize 选项。

crossOrigin null | string | undefined 已加载图像的 crossOrigin 属性。注意如果要使用 Canvas 渲染器访问像素数据,必须提供 crossOrigin 值。详见 https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image。
referrerPolicy ReferrerPolicy | undefined

已加载图像的 referrerPolicy 属性。

interpolate boolean (defaults to true)

重采样时是否使用插值。默认情况下, 重采样时使用线性插值。设置为 false 可使用 the nearest neighbor instead.

tileGrid WMTSTileGrid

瓦片网格。

projection ProjectionLike | undefined

投影。默认为视图投影。

reprojectionErrorThreshold number (defaults to 0.5)

允许的最大重投影误差(以像素为单位)。 值越高可以提高重投影性能,但会降低精度。

requestEncoding RequestEncoding (defaults to 'KVP')

请求编码。

layer string

WMTS 能力中公布的图层名称。

style string

WMTS 能力中公布的样式名称。

tileClass Class<ImageTile> | undefined

用于实例化图像瓦片的类。默认为 ImageTile

tilePixelRatio number (defaults to 1)

瓦片服务使用的像素比。例如,如果瓦片服务宣传 256x256 像素瓦片但实际发送 512x512 像素图像(用于 retina/hidpi 设备),则 tilePixelRatio 应设置为 2

format string (defaults to 'image/jpeg')

图像格式。仅在 requestEncoding'KVP' 时使用。

version string (defaults to '1.0.0')

WMTS 版本。

matrixSet string

矩阵集。

dimensions Object | undefined

瓦片请求的额外"维度"。这是一个对象,其属性名称与公布的 WMTS 维度相同。

url string | undefined

服务的 URL。对于 RESTful 请求编码,这是一个 URL 模板。对于 KVP 编码,这是一个普通 URL。可以使用 {?-?} 模板模式(例如 subdomain{a-f}.domain.com)来代替在 urls 选项中逐个定义。

tileLoad函数 Load函数 | undefined

给定 URL 加载瓦片的可选函数。默认为

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

URL 数组。请求将在此数组中的 URL 之间分配。

wrapX boolean (defaults to false)

是否水平环绕世界。

transition number | undefined

渲染的不透明度过渡持续时间。要禁用不透明度过渡,请传递 transition: 0

zDirection number | NearestDirection函数 (defaults to 0)

选择在整数缩放级别之间使用更高还是更低缩放级别的瓦片。参见 getZForResolution

触发事件:

Extends

Methods

增加修订计数器并分发 'change' 事件。

移除数据源中所有缓存的重投影瓦片。下一个渲染周期将创建新的瓦片。

dispatchEvent(event){boolean | undefined} inherited

分发事件并调用所有监听此类型事件的监听器。事件参数可以是一个字符串或一个 具有 type 属性的对象。

Name Type Description
event BaseEvent | string

事件对象。

返回值:
如果有人在事件对象上调用了 preventDefault 或任何监听器返回 false,则返回 false

获取一个值。

Name Type Description
key string

键名。

返回值:
值。

获取数据源的归属函数。

返回值:
Attribution function.

getAttributionsCollapsible(){boolean} inherited

返回值:
归属信息是否可折叠。

getDimensions(){Object}

获取维度,即通过"dimensions"选项传递给构造函数的维度,可能已通过 updateDimensions 方法更新。

返回值:
维度。

getFormat(){string}

返回image format of the WMTS source.

返回值:
Format.

getKeys(){Array.<string>} inherited

获取对象属性名列表。

返回值:
属性名列表。

getLayer(){string}

返回layer of the WMTS source.

返回值:
图层。

getMatrixSet(){string}

返回matrix set of the WMTS source.

返回值:
MatrixSet.

getProjection(){Projection | null} inherited

获取数据源的投影。

返回值:
投影。

getProperties(){NoInfer.<Properties>} inherited

获取包含所有属性名和值的对象。

返回值:
对象。

getRequestEncoding(){RequestEncoding}

返回请求编码,为"KVP"或"REST"。

返回值:
请求编码。

getRevision(){number} inherited

获取此对象的版本号。 每次对象被修改时,其版本号将递增。

返回值:
版本号。

获取数据源的状态,可能的状态参见 State。

返回值:
状态。

getStyle(){string}

返回style of the WMTS source.

返回值:
样式。

getTileGrid(){TileGrid | null} inherited

返回瓦片数据源的瓦片网格。

返回值:
瓦片网格。

已弃用。 请改用 ImageTile 数据源。 返回数据源的瓦片加载函数。

返回值:
TileLoad函数

已弃用。 请改用 ImageTile 数据源。 返回数据源的瓦片 URL 函数。

返回值:
TileUrl函数

getUrls(){!Array.<string> | null} inherited

已弃用。 请改用 ImageTile 数据源。 返回此数据源使用的 URL。 当使用 tileUrl函数 时ad of url or urls, null will be returned.

返回值:
URL 列表。

getVersion(){string}

返回version of the WMTS source.

返回值:
Version.

on(type, listener){EventsKey | Array<EventsKey>} inherited

监听特定类型的事件。

Name Type Description
type string | Array.<string>

事件类型或事件类型数组。

listener function

监听器函数。

返回值:
监听器的唯一键。如果第一个参数是事件类型数组,则返回键的数组。

once(type, listener){EventsKey | Array<EventsKey>} inherited

仅监听一次特定类型的事件。

Name Type Description
type string | Array.<string>

事件类型或事件类型数组。

listener function

监听器函数。

返回值:
监听器的唯一键。如果第一个参数是事件类型数组,则返回键的数组。

set(key, value, silent) inherited

设置一个值。

Name Type Description
key string

键名。

value *

值。

silent boolean | undefined

更新但不触发事件。

setAttributions(attributions) inherited

设置数据源的归属信息。

Name Type Description
attributions AttributionLike | undefined

归属信息。可以作为字符串、Array<string>、Attribution 或 undefined 传入。

setProperties(values, silent) inherited

设置一组键值对。 注意,这会更改任何现有属性并添加新属性(不会移除任何现有属性)。

Name Type Description
values Partial.<NoInfer.<Properties>>

值。

silent boolean | undefined

更新但不触发事件。

setRenderReprojectionEdges(render) inherited

设置是否渲染重投影边缘(通常用于调试)。

Name Type Description
render boolean

渲染边缘。

setTileGridForProjection(projection, tilegrid) inherited

设置在将瓦片重投影到给定投影时使用的瓦片网格, 而不是默认的瓦片网格rojection.

当无法创建默认瓦片网格(例如投影未定义范围)或出于优化原因(自定义瓦片尺寸、分辨率等)时,这可能很有用。

Name Type Description
projection ProjectionLike

投影。

tilegrid TileGrid

用于投影的瓦片网格。

setTileLoad函数(tileLoad函数) inherited

已弃用。 请改用 ImageTile 数据源。 设置数据源的瓦片加载函数。

Name Type Description
tileLoad函数 Load函数

瓦片加载函数。

setTileUrl函数(tileUrl函数, key) inherited

已弃用。 请改用 ImageTile 数据源。 设置数据源的瓦片 URL 函数。

Name Type Description
tileUrl函数 Url函数

瓦片 URL 函数。

key string | undefined

数据源的可选新瓦片键。

设置用于请求的 URL。

Name Type Description
url string

URL.

un(type, listener) inherited

取消监听特定类型的事件。

Name Type Description
type string | Array.<string>

事件类型或事件类型数组。

listener function

监听器函数。

unset(key, silent) inherited

取消设置一个属性。

Name Type Description
key string

键名。

silent boolean | undefined

取消设置但不触发事件。

updateDimensions(dimensions)

更新维度。

Name Type Description
dimensions Object

维度。