English中文

WebMapTileServiceImageryProvider

new Cesium.WebMapTileServiceImageryProvider(options)

提供由以下服务提供的平铺图像 Provides tiled imagery served by WMTS 1.0.0 兼容的服务器。此提供程序支持 HTTP KVP 编码和 RESTful GetTile 请求,但尚不支持 SOAP 编码。 compliant servers. This provider supports HTTP KVP-encoded and RESTful GetTile requests, but does not yet support the SOAP encoding.
名称 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 The default parameters to include in the WMTS URL to obtain images. The values are as follows: service=WMTS version=1.0.0 request=GetTile

static constant Cesium.WebMapTileServiceImageryProvider.GetFeatureInfoDefaultParameters : object

WMTS URL 中包含的默认参数以获取功能信息。值如下: service=WMTS version=1.0.0 request=GetFeatureInfo The default parameters to include in the WMTS URL to get feature information. The values are as follows: service=WMTS version=1.0.0 request=GetFeatureInfo
获取或设置一个时钟,用于获取保存时间动态参数所用的时间。 Gets or sets a clock that is used to get keep the time used for time dynamic parameters.
获取此图像提供程序处于活动状态时要显示的信用。通常,这用于证明图像的来源。 Gets the credit to display when this imagery provider is active. Typically this is used to credit the source of the imagery.
获取或设置包含静态尺寸及其值的对象。 Gets or sets an object that contains static dimensions and their values.
获取或设置一个值,该值指示是否启用特征拾取。如果属实的话, Gets or sets a value indicating whether feature picking is enabled. If true, WebMapTileServiceImageryProvider#pickFeatures 将调用 will invoke the GetFeatureInfo WMTS 服务器上的服务并尝试解释响应中包含的功能。如果是假的, service on the WMTS server and attempt to interpret the features included in the response. If false, WebMapTileServiceImageryProvider#pickFeatures 将立即返回未定义(表示没有可选择的功能),而不与服务器通信。如果您知道您的数据源不支持选择功能或者您不希望该提供程序的功能可供选择,请将此属性设置为 false。 KVP 编码默认为 true。对于 RESTful 编码,仅在以下情况下默认为 true will immediately return undefined (indicating no pickable features) without communicating with the server. Set this property to false if you know your data source does not support picking features or if you don't want this provider's features to be pickable. Defaults to true for KVP encoding. For RESTful encoding, defaults to true only when WebMapTileServiceImageryProvider.ConstructorOptions#getFeatureInfoUrl 已指定,否则为 false。 is specified, and false otherwise.
获取当图像提供程序遇到异步错误时引发的事件。通过订阅该事件,您将收到错误通知,并有可能从中恢复。事件监听器传递一个实例 Gets an event that is raised when the imagery provider encounters an asynchronous error. By subscribing to the event, you will be notified of the error and can potentially recover from it. Event listeners are passed an instance of TileProviderError.
获取此图像提供程序返回的图像的 mime 类型。 Gets the mime type of images returned by this imagery provider.
获取 WMTS 服务器的 getFeatureInfo URL。 Gets the getFeatureInfo URL of the WMTS server.
获取一个值,该值指示此图像提供程序提供的图像是否包含 Alpha 通道。如果此属性为 false,则 Alpha 通道(如果存在)将被忽略。如果此属性为 true,则任何没有 Alpha 通道的图像都将被视为其 Alpha 在任何地方都是 1.0。当此属性为 false 时,内存使用量和纹理上传时间都会减少。 Gets a value indicating whether or not the images provided by this imagery provider include an alpha channel. If this property is false, an alpha channel, if present, will be ignored. If this property is true, any images without an alpha channel will be treated as if their alpha is 1.0 everywhere. When this property is false, memory usage and texture upload time are reduced.

readonly maximumLevel : number|undefined

获取可以请求的最大详细程度。 Gets the maximum level-of-detail that can be requested.
获取可以请求的最低详细程度。 Gets the minimum level-of-detail that can be requested.
获取此提供者使用的代理。 Gets the proxy used by this provider.
获取此实例提供的图像的矩形(以弧度为单位)。 Gets the rectangle, in radians, of the imagery provided by this instance.
获取图块丢弃策略。如果未定义,则丢弃策略负责通过其 shouldDiscardImage 函数过滤掉“丢失”的图块。如果此函数返回未定义,则不会过滤任何图块。 Gets the tile discard policy. If not undefined, the discard policy is responsible for filtering out "missing" tiles via its shouldDiscardImage function. If this function returns undefined, no tiles are filtered.
获取每个图块的高度(以像素为单位)。 Gets the height of each tile, in pixels.
获取每个图块的宽度(以像素为单位)。 Gets the width of each tile, in pixels.
获取此提供程序使用的切片方案。 Gets the tiling scheme used by this provider.
获取或设置用于获取时间动态参数的时间间隔集合。每个 TimeInterval 的数据是一个对象,其中包含在图块请求期间使用的属性的键和值。 Gets or sets a time interval collection that is used to get time dynamic parameters. The data of each TimeInterval is an object containing the keys and values of the properties that are used during tile requests.
获取托管图像的服务的 URL。 Gets the URL of the service hosting the imagery.

方法 Methods

获取显示给定图块时要显示的积分。 Gets the credits to be displayed when a given tile is displayed.
名称 Name 类型 Type 说明 Description
x number 平铺 X 坐标。 The tile X coordinate.
y number 平铺 Y 坐标。 The tile Y coordinate.
level number 瓷砖水平; The tile level;
返回: Returns:
显示图块时要显示的制作人员名单。 The credits to be displayed when the tile is displayed.

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

异步确定哪些要素(如果有)位于切片内给定经度和纬度处。 Asynchronously determines what features, if any, are located at a given longitude and latitude within a tile.
名称 Name 类型 Type 说明 Description
x number 平铺 X 坐标。 The tile X coordinate.
y number 平铺 Y 坐标。 The tile Y coordinate.
level number 瓷砖级别。 The tile level.
longitude number 选择要素的经度。 The longitude at which to pick features.
latitude number 选择特征的纬度。 The latitude at which to pick features.
返回: Returns:
对所选取功能的承诺将在异步选取完成时解决。解析后的值是一个数组 A promise for the picked features that will resolve when the asynchronous picking completes. The resolved value is an array of ImageryLayerFeatureInfo 实例。如果在给定位置未找到要素,则数组可能为空。 instances. The array may be empty if no features are found at the given location.

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

请求给定图块的图像。 Requests the image for a given tile.
名称 Name 类型 Type 说明 Description
x number 平铺 X 坐标。 The tile X coordinate.
y number 平铺 Y 坐标。 The tile Y coordinate.
level number 瓷砖级别。 The tile level.
request Request 可选 optional 请求对象。仅供内部使用。 The request object. Intended for internal use only.
返回: Returns:
对图像的承诺,该承诺将在图像可用时解析,或者如果对服务器的活动请求太多,则未定义,并且应稍后重试该请求。 A promise for the image that will resolve when the image is available, or undefined if there are too many active requests to the server, and the request should be retried later.

类型定义 Type Definitions

Cesium.WebMapTileServiceImageryProvider.ConstructorOptions

WebMapTileServiceImageryProvider 构造函数的初始化选项 Initialization options for the WebMapTileServiceImageryProvider constructor
属性: Properties:
名称 Name 类型 Type Attributes 默认值 Default 说明 Description
url Resource | string WMTS GetTile 操作的基本 URL(对于 KVP 编码的请求)或图块 URL 模板(对于 RESTful 请求)。 tile-URL 模板应包含以下变量:{style}、{TileMatrixSet}、{TileMatrix}、{TileRow}、{TileCol}。如果实际值是硬编码的或者服务器不需要,前两个是可选的。 {s} 关键字可用于指定子域。 The base URL for the WMTS GetTile operation (for KVP-encoded requests) or the tile-URL template (for RESTful requests). The tile-URL template should contain the following variables: &#123;style&#125;, &#123;TileMatrixSet&#125;, &#123;TileMatrix&#125;, &#123;TileRow&#125;, &#123;TileCol&#125;. The first two are optional if actual values are hardcoded or not required by the server. The &#123;s&#125; keyword may be used to specify subdomains.
format string <可选> &lt;optional>
'image/jpeg' 从服务器检索图像的 MIME 类型。 The MIME type for images to retrieve from the server.
layer string WMTS 请求的图层名称。 The layer name for WMTS requests.
style string WMTS 请求的样式名称。 The style name for WMTS requests.
tileMatrixSetID string 用于 WMTS 请求的 TileMatrixSet 的标识符。 The identifier of the TileMatrixSet to use for WMTS requests.
enablePickFeatures boolean <可选> &lt;optional>
如果属实的话, If true, WebMapTileServiceImageryProvider#pickFeatures 将调用 WMTS 服务器上的 GetFeatureInfo 操作并返回响应中包含的功能。如果是假的, will invoke the GetFeatureInfo operation on the WMTS server and return the features included in the response. If false, WebMapTileServiceImageryProvider#pickFeatures 将立即返回未定义(表示没有可选择的功能),而不与服务器通信。如果您知道 WMTS 服务器不支持 GetFeatureInfo 或者您不希望选择该提供程序的功能,请将此属性设置为 false。 KVP 编码默认为 true。对于 RESTful 编码,仅在以下情况下默认为 true will immediately return undefined (indicating no pickable features) without communicating with the server. Set this property to false if you know your WMTS server does not support GetFeatureInfo or if you don't want this provider's features to be pickable. Defaults to true for KVP encoding. For RESTful encoding, defaults to true only when WebMapTileServiceImageryProvider.ConstructorOptions#getFeatureInfoUrl 已指定,否则为 false。 is specified, and false otherwise.
getFeatureInfoParameters object <可选> &lt;optional>
GetFeatureInfo 请求中包含的其他参数。按键内部小写。 Additional parameters to include in GetFeatureInfo requests. Keys are lowercased internally.
getFeatureInfoUrl Resource | string <可选> &lt;optional>
WMTS 服务的 GetFeatureInfo URL。如果未指定,则值为 The GetFeatureInfo URL of the WMTS service. If not specified, the value of url 被使用。 is used.
getFeatureInfoFormats Array.<GetFeatureInfoFormat> <可选> &lt;optional>
WebMapTileServiceImageryProvider.DefaultGetFeatureInfoFormats 尝试 WMTS GetFeatureInfo 请求的格式。 The formats in which to try WMTS GetFeatureInfo requests.
rectangle Rectangle <可选> &lt;optional>
Rectangle.MAX_VALUE 被图层覆盖的矩形。 The rectangle covered by the layer.
tilingScheme TilingScheme <可选> &lt;optional>
与 TileMatrixSet 中的切片组织相对应的切片方案。 The tiling scheme corresponding to the organization of the tiles in the TileMatrixSet.
ellipsoid Ellipsoid <可选> &lt;optional>
椭球体。如果未指定,则使用 WGS84 椭球。 The ellipsoid. If not specified, the WGS84 ellipsoid is used.
tileWidth number <可选> &lt;optional>
256 平铺宽度(以像素为单位)。 The tile width in pixels.
tileHeight number <可选> &lt;optional>
256 平铺高度(以像素为单位)。 The tile height in pixels.
minimumLevel number <可选> &lt;optional>
0 图像提供商支持的最低细节级别。 The minimum level-of-detail supported by the imagery provider.
maximumLevel number <可选> &lt;optional>
图像提供者支持的最大细节级别,如果没有限制则未定义。 The maximum level-of-detail supported by the imagery provider, or undefined if there is no limit.
tileMatrixLabels Array <可选> &lt;optional>
TileMatrix 中用于 WMTS 请求的标识符列表,每个 TileMatrix 级别一个。 A list of identifiers in the TileMatrix to use for WMTS requests, one per TileMatrix level.
credit Credit | string <可选> &lt;optional>
数据源的来源,显示在画布上。 A credit for the data source, which is displayed on the canvas.
subdomains string | Array.<string> <可选> &lt;optional>
'abc' 用于的子域 The subdomains to use for the {s} URL 模板中的占位符。如果此参数是单个字符串,则字符串中的每个字符都是一个子域。如果是数组,则数组中的每个元素都是一个子域。 placeholder in the URL template. If this parameter is a single string, each character in the string is a subdomain. If it is an array, each element in the array is a subdomain.
clock Clock <可选> &lt;optional>
确定时间维度值时使用的 Clock 实例。指定“times”时需要。 A Clock instance that is used when determining the value for the time dimension. Required when `times` is specified.
times TimeIntervalCollection <可选> &lt;optional>
TimeIntervalCollection 及其 TimeIntervalCollection with its data 属性是包含时间动态维度及其值的对象。 property being an object containing time dynamic dimension and their values.
dimensions object <可选> &lt;optional>
包含静态尺寸及其值的对象。 A object containing static dimensions and their values.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.