WebMapTileServiceImageryProvider

new Cesium.WebMapTileServiceImageryProvider(options)

提供由符合 WMTS 1.0.0 标准的服务器所托管的瓦片影像。此提供者支持 HTTP KVP 编码和 RESTful 的 GetTile 请求,但尚未支持 SOAP 编码。
Name Type Description
options WebMapTileServiceImageryProvider.ConstructorOptions Object describing initialization options
Examples:
// Example 1. USGS shaded relief tiles (KVP)
const shadedRelief1 = new Cesium.WebMapTileServiceImageryProvider({
    url : 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS',
    layer : 'USGSShadedReliefOnly',
    style : 'default',
    format : 'image/jpeg',
    tileMatrixSetID : 'default028mm',
    // tileMatrixLabels : ['default028mm:0', 'default028mm:1', 'default028mm:2' ...],
    maximumLevel: 19,
    credit : new Cesium.Credit('U. S. Geological Survey')
});
viewer.imageryLayers.addImageryProvider(shadedRelief1);
// Example 2. USGS shaded relief tiles (RESTful)
const shadedRelief2 = new Cesium.WebMapTileServiceImageryProvider({
    url : 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSShadedReliefOnly/MapServer/WMTS/tile/1.0.0/USGSShadedReliefOnly/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.jpg',
    layer : 'USGSShadedReliefOnly',
    style : 'default',
    format : 'image/jpeg',
    tileMatrixSetID : 'default028mm',
    maximumLevel: 19,
    credit : new Cesium.Credit('U. S. Geological Survey')
});
viewer.imageryLayers.addImageryProvider(shadedRelief2);
// Example 3: NASA time dynamic snowpack data (RESTful)
// Define time intervals for the layer based on the capabilities XML
const times = Cesium.TimeIntervalCollection.fromIso8601({
    iso8601: '2025-01-01/2025-09-01/P5D', // Use the valid interval(s) from the Dimension section
    dataCallback: function(interval, index) {
      // Return an object with the Time variable used in the URL template
      return {
          Time: Cesium.JulianDate.toIso8601(interval.start, 0)
      };
  }
});
// Get the internal clock,  set desired start, stop, and multiplier
const clock = viewer.clock;
clock.startTime = Cesium.JulianDate.fromIso8601('2025-01-01');
clock.currentTime = Cesium.JulianDate.fromIso8601('2025-01-01');
clock.stopTime = Cesium.JulianDate.fromIso8601('2025-09-01');
clock.clockRange = Cesium.ClockRange.LOOP_STOP;
clock.multiplier = 1; // 1 day per second
clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK_MULTIPLIER;

viewer.timeline.zoomTo(clock.startTime, clock.stopTime);

const weather = new Cesium.WebMapTileServiceImageryProvider({
    url: 'https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/AMSRU2_Snow_Water_Equivalent_5Day/default/{Time}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png',
    layer: 'AMSRU2_Snow_Water_Equivalent_5Day',
    style: 'default',
    tileMatrixSetID: 'GoogleMapsCompatible_Level6',
    format: 'image/png',
    clock: clock,
    times: times,
    credit: new Cesium.Credit('NASA Global Imagery Browse Services for EOSDIS')
});
viewer.imageryLayers.addImageryProvider(weather);
// Example 4. Digital Earth AfricA waterbodies with GetFeatureInfo support (RESTful)
const waterbodies = new Cesium.WebMapTileServiceImageryProvider({
   url: "https://geoserver.digitalearth.africa/geoserver/gwc/service/wmts/rest/{layer}/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}?format={format}",
   layer: "waterbodies:DEAfrica_Waterbodies",
   style: "waterbodies:waterbodies_v0_0_4",
   tileMatrixSetID: "EPSG:3857",
   tileMatrixLabels: [
     "EPSG:3857:0",
     "EPSG:3857:1",
     "EPSG:3857:2",
     "EPSG:3857:3",
     "EPSG:3857:4",
     "EPSG:3857:5",
     "EPSG:3857:6",
     "EPSG:3857:7",
     "EPSG:3857:8",
     "EPSG:3857:9",
     "EPSG:3857:10",
     "EPSG:3857:11",
     "EPSG:3857:12",
     "EPSG:3857:13",
     "EPSG:3857:14",
     "EPSG:3857:15",
     "EPSG:3857:16",
     "EPSG:3857:17",
     "EPSG:3857:18",
     "EPSG:3857:19",
     "EPSG:3857:20",
     "EPSG:3857:21",
     "EPSG:3857:22",
     "EPSG:3857:23",
     "EPSG:3857:24",
     "EPSG:3857:25",
     "EPSG:3857:26",
     "EPSG:3857:27",
     "EPSG:3857:28",
     "EPSG:3857:29",
     "EPSG:3857:30",
   ],
   format: "image/png",
   enablePickFeatures: true,
   getFeatureInfoUrl: "https://geoserver.digitalearth.africa/geoserver/gwc/service/wmts/rest/{layer}/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{j}/{i}?format={format}",
});

viewer.imageryLayers.addImageryProvider(waterbodies);
Demo:
See:

Members

static constant Cesium.WebMapTileServiceImageryProvider.DefaultParameters : object

包含在 WMTS URL 中以获取图像的默认参数。 其值如下: service=WMTS version=1.0.0 request=GetTile

static constant Cesium.WebMapTileServiceImageryProvider.GetFeatureInfoDefaultParameters : object

包含在 WMTS URL 中以获取要素信息的默认参数。 其值如下: service=WMTS version=1.0.0 request=GetFeatureInfo
获取或设置一个时钟(clock),用于获取并保持时间动态参数所使用的时间。
获取当此影像提供者处于活动状态时要显示的版权信息(credit)。通常这用于标注影像的来源。
获取或设置一个包含静态维度(dimensions)及其值的对象。
获取或设置一个指示是否启用要素拾取(feature picking)的值。如果为 true,WebMapTileServiceImageryProvider#pickFeatures 会调用 WMTS 服务器上的 GetFeatureInfo 服务,并尝试解析响应中包含的要素。如果为 false,WebMapTileServiceImageryProvider#pickFeatures 会立即返回 undefined(表示无可拾取要素),而不与服务器通信。如果您知道数据源不支持要素拾取,或者不希望此提供者的要素可被拾取,请将此属性设为 false。对于 KVP 编码,默认为 true。对于 RESTful 编码,仅当指定了 WebMapTileServiceImageryProvider.ConstructorOptions#getFeatureInfoUrl 时默认为 true,否则为 false。
获取当影像提供者遇到异步错误时引发的事件。通过订阅该事件,您将收到错误通知,并有可能从中恢复。事件监听器会收到一个 TileProviderError 的实例。
获取此影像提供者返回的图像的 MIME 类型。
获取 WMTS 服务器的 getFeatureInfo URL。
获取一个指示此影像提供者提供的图像是否包含 alpha 通道的值。如果此属性为 false,则 alpha 通道(如果存在)将被忽略。如果此属性为 true,则任何没有 alpha 通道的图像都会被视为其 alpha 在所有位置都为 1.0。当此属性为 false 时,内存使用量和纹理上传时间都会减少。

readonly maximumLevel : number|undefined

获取可请求的最大细节层次(level-of-detail)。
获取可请求的最小细节层次(level-of-detail)。
获取此提供者使用的代理(proxy)。
获取此实例提供的影像的矩形区域,以弧度表示。
获取瓦片丢弃策略(tile discard policy)。如果不为 undefined,该丢弃策略负责通过其 shouldDiscardImage 函数过滤掉“缺失”的瓦片。如果该函数返回 undefined,则不会过滤任何瓦片。
获取每个瓦片的高度,以像素为单位。
获取每个瓦片的宽度,以像素为单位。
获取此提供者使用的分块方案(tiling scheme)。
获取或设置一个时间间隔集合(TimeIntervalCollection),用于获取时间动态参数。每个 TimeInterval 的数据是一个对象,包含瓦片请求期间所使用的属性的键和值。
获取托管影像的服务的 URL。

Methods

获取在显示给定瓦片时要显示的版权信息(credits)。
Name Type Description
x number 瓦片的 X 坐标。
y number 瓦片的 Y 坐标。
level number 瓦片的层次(level);
Returns:
在显示该瓦片时要显示的版权信息(credits)。

pickFeatures(x, y, level, longitude, latitude)Promise.<Array.<ImageryLayerFeatureInfo>>|undefined

异步确定在给定的经度和纬度处(位于某个瓦片内)存在哪些要素(如果有)。
Name Type Description
x number 瓦片的 X 坐标。
y number 瓦片的 Y 坐标。
level number 瓦片的层次(level)。
longitude number 拾取要素所在的经度。
latitude number 拾取要素所在的纬度。
Returns:
一个用于已拾取要素的 promise,将在异步拾取完成时解析。解析后的值是一个由 ImageryLayerFeatureInfo 实例组成的数组。如果在给定位置未找到任何要素,该数组可能为空。

requestImage(x, y, level, request)Promise.<ImageryTypes>|undefined

请求给定瓦片的图像。
Name Type Description
x number 瓦片的 X 坐标。
y number 瓦片的 Y 坐标。
level number 瓦片的层次(level)。
request Request optional 请求对象。仅供内部使用。
Returns:
一个用于图像的 promise,将在图像可用时解析;如果到服务器的活动请求过多,请求应稍后重试,则返回 undefined。

Type Definitions

Cesium.WebMapTileServiceImageryProvider.ConstructorOptions

Initialization options for the WebMapTileServiceImageryProvider constructor
Properties:
Name Type Attributes Default Description
url Resource | string WMTS GetTile 操作(针对 KVP 编码请求)的基础 URL,或瓦片 URL 模板(针对 RESTful 请求)。瓦片 URL 模板应包含以下变量: {style}、{TileMatrixSet}、{TileMatrix}、{TileRow}、{TileCol}。如果实际值已硬编码,或者服务器不需要,则前两个变量是可选的。可以使用 {s} 关键字来指定子域。
format string <optional>
'image/jpeg' 从服务器检索的图像的 MIME 类型。
layer string WMTS 请求的图层名称。
style string WMTS 请求的样式名称。
tileMatrixSetID string 用于 WMTS 请求的 TileMatrixSet 的标识符。
enablePickFeatures boolean <optional>
如果为 true,WebMapTileServiceImageryProvider#pickFeatures 会调用 WMTS 服务器上的 GetFeatureInfo 操作,并返回响应中包含的要素。如果为 false,WebMapTileServiceImageryProvider#pickFeatures 会立即返回 undefined(表示无可拾取要素),而不与服务器通信。如果您知道 WMTS 服务器不支持 GetFeatureInfo,或者不希望此提供者的要素可被拾取,请将此属性设为 false。对于 KVP 编码,默认为 true。对于 RESTful 编码,仅当指定了 WebMapTileServiceImageryProvider.ConstructorOptions#getFeatureInfoUrl 时默认为 true,否则为 false。
getFeatureInfoParameters object <optional>
包含在 GetFeatureInfo 请求中的附加参数。键(keys)在内部会被转换为小写。
getFeatureInfoUrl Resource | string <optional>
WMTS 服务的 GetFeatureInfo URL。如果未指定,则使用 url 的值。
getFeatureInfoFormats Array.<GetFeatureInfoFormat> <optional>
WebMapTileServiceImageryProvider.DefaultGetFeatureInfoFormats 尝试 WMTS GetFeatureInfo 请求时使用的格式。
rectangle Rectangle <optional>
Rectangle.MAX_VALUE 图层所覆盖的矩形区域。
tilingScheme TilingScheme <optional>
与 TileMatrixSet 中瓦片的组织方式相对应的分块方案(tiling scheme)。
ellipsoid Ellipsoid <optional>
椭球体。如果未指定,则使用 WGS84 椭球体。
tileWidth number <optional>
256 瓦片的宽度,以像素为单位。
tileHeight number <optional>
256 瓦片的高度,以像素为单位。
minimumLevel number <optional>
0 影像提供者支持的最小细节层次(level-of-detail)。
maximumLevel number <optional>
影像提供者支持的最大细节层次(level-of-detail),如果没有限制则为 undefined。
tileMatrixLabels Array <optional>
用于 WMTS 请求的 TileMatrix 中的标识符列表,每个 TileMatrix 级别对应一个。
credit Credit | string <optional>
数据源的版权信息(credit),显示在画布上。
subdomains string | Array.<string> <optional>
'abc' 用于 URL 模板中 {s} 占位符的子域(subdomains)。如果此参数是一个字符串,则字符串中的每个字符都是一个子域。如果是一个数组,则数组中的每个元素都是一个子域。
clock Clock <optional>
在确定时间维度的值时所使用的 Clock 实例。当指定 `times` 时为必填。
times TimeIntervalCollection <optional>
TimeIntervalCollection,其 data 属性为一个包含时间动态维度及其值的对象。
dimensions object <optional>
一个包含静态维度(dimensions)及其值的对象。
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。.