English中文

UrlTemplateImageryProvider

new Cesium.UrlTemplateImageryProvider(options)

通过使用指定的 URL 模板请求图块来提供图像。 Provides imagery by requesting tiles using a specified URL template.
名称 Name 类型 Type 说明 Description
options UrlTemplateImageryProvider.ConstructorOptions 描述初始化选项的对象 Object describing initialization options
示例: Example:
// Access Natural Earth II imagery, which uses a TMS tiling scheme and Geographic (EPSG:4326) project
const tms = new Cesium.UrlTemplateImageryProvider({
    url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII') + '/{z}/{x}/{reverseY}.jpg',
    tilingScheme : new Cesium.GeographicTilingScheme(),
    maximumLevel : 5
});
// Access the CartoDB Positron basemap, which uses an OpenStreetMap-like tiling scheme.
const positron = new Cesium.UrlTemplateImageryProvider({
    url : 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
    credit : 'Map tiles by CartoDB, under CC BY 3.0. Data by OpenStreetMap, under ODbL.'
});
// Access a Web Map Service (WMS) server.
const wms = new Cesium.UrlTemplateImageryProvider({
   url : 'https://services.ga.gov.au/gis/services/NM_Hydrology_and_Marine_Points/MapServer/WMSServer?' +
         'tiled=true&transparent=true&format=image%2Fpng&exceptions=application%2Fvnd.ogc.se_xml&' +
         'styles=&service=WMS&version=1.3.0&request=GetMap&' +
         'layers=Bores&crs=EPSG%3A3857&' +
         'bbox={westProjected}%2C{southProjected}%2C{eastProjected}%2C{northProjected}&' +
         'width=256&height=256',
   rectangle : Cesium.Rectangle.fromDegrees(95.0, -55.0, 170.0, -1.0)  // From GetCapabilities EX_GeographicBoundingBox
});
// Using custom tags in your template url.
const custom = new Cesium.UrlTemplateImageryProvider({
   url : 'https://yoururl/{Time}/{z}/{y}/{x}.png',
   customTags : {
       Time: function(imageryProvider, x, y, level) {
           return '20171231'
       }
   }
});
另见: See:

成员 Members

获取此图像提供程序处于活动状态时要显示的信用。通常,这用于证明图像的来源。 Gets the credit to display when this imagery provider is active. Typically this is used to credit the source of the imagery.
默认值: Default Value: undefined
获取或设置一个值,该值指示是否启用特征拾取。如果属实的话, Gets or sets a value indicating whether feature picking is enabled. If true, UrlTemplateImageryProvider#pickFeatures 将要求 will request the options.pickFeaturesUrl 并尝试解释响应中包含的功能。如果是假的, and attempt to interpret the features included in the response. If false, UrlTemplateImageryProvider#pickFeatures 将立即返回未定义(表示没有可选择的功能),而不与服务器通信。如果您知道您的数据源不支持选择功能或者您不希望该提供程序的功能可供选择,请将此属性设置为 false。 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.
默认值: Default Value: true
获取当图像提供程序遇到异步错误时引发的事件。通过订阅该事件,您将收到错误通知,并有可能从中恢复。事件监听器传递一个实例 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.

readonly hasAlphaChannel : boolean

获取一个值,该值指示此图像提供程序提供的图像是否包含 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.
默认值: Default Value: true

readonly maximumLevel : number|undefined

获取可以请求的最大详细级别,如果没有限制则为未定义。 Gets the maximum level-of-detail that can be requested, or undefined if there is no limit.
默认值: Default Value: undefined
获取可以请求的最低详细程度。 Gets the minimum level-of-detail that can be requested.
默认值: Default Value: 0

readonly pickFeaturesUrl : string

获取用于选择要素的 URL 模板。如果未指定此属性, Gets the URL template to use to use to pick features. If this property is not specified, UrlTemplateImageryProvider#pickFeatures 将立即返回未定义,表示没有选择任何功能。 URL 模板支持所有受支持的关键字 will immediately return undefined, indicating no features picked. The URL template supports all of the keywords supported by the UrlTemplateImageryProvider#url 财产,加上以下内容: property, plus the following:
  • {i}:拾取位置的像素列(水平坐标),最西边的像素为0。 : The pixel column (horizontal coordinate) of the picked position, where the Westernmost pixel is 0.
  • {j}:拾取位置的像素行(垂直坐标),其中最北像素为 0。 : The pixel row (vertical coordinate) of the picked position, where the Northernmost pixel is 0.
  • {reverseI}:拾取位置的像素列(水平坐标),其中最东边的像素为0。 : The pixel column (horizontal coordinate) of the picked position, where the Easternmost pixel is 0.
  • {reverseJ}:拾取位置的像素行(垂直坐标),其中最南端的像素为 0。 : The pixel row (vertical coordinate) of the picked position, where the Southernmost pixel is 0.
  • {longitudeDegrees}:所选位置的经度(以度为单位)。 : The longitude of the picked position in degrees.
  • {latitudeDegrees}:所选位置的纬度(以度为单位)。 : The latitude of the picked position in degrees.
  • {longitudeProjected}:切片方案投影坐标中选取位置的经度。 : The longitude of the picked position in the projected coordinates of the tiling scheme.
  • {latitudeProjected}:切片方案投影坐标中选取位置的纬度。 : The latitude of the picked position in the projected coordinates of the tiling scheme.
  • {format}:获取特征信息的格式,如 : The format in which to get feature information, as specified in the GetFeatureInfoFormat.
获取此提供者使用的代理。 Gets the proxy used by this provider.
默认值: Default Value: undefined
获取此实例提供的图像的矩形(以弧度为单位)。 Gets the rectangle, in radians, of the imagery provided by this instance.
默认值: Default Value: tilingScheme.rectangle
获取图块丢弃策略。如果未定义,则丢弃策略负责通过其 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.
默认值: Default Value: undefined
获取每个图块的高度(以像素为单位)。 Gets the height of each tile, in pixels.
默认值: Default Value: 256
获取每个图块的宽度(以像素为单位)。 Gets the width of each tile, in pixels.
默认值: Default Value: 256
获取此提供程序使用的切片方案。 Gets the tiling scheme used by this provider.
默认值: Default Value: new WebMercatorTilingScheme()
获取用于请求图块的 URL 模板。它有以下关键词: Gets the URL template to use to request tiles. It has the following keywords:
  • {z}: The level of the tile in the tiling scheme. Level zero is the root of the quadtree pyramid.
  • {x}:切片方案中切片的 X 坐标,其中 0 是最西边的切片。 : The tile X coordinate in the tiling scheme, where 0 is the Westernmost tile.
  • {y}:切片方案中切片的 Y 坐标,其中 0 是最北的切片。 : The tile Y coordinate in the tiling scheme, where 0 is the Northernmost tile.
  • {s}:可用子域之一,用于克服浏览器对每个主机同时请求数量的限制。 : One of the available subdomains, used to overcome browser limits on the number of simultaneous requests per host.
  • {reverseX}:切片方案中图块的 X 坐标,其中 0 是最东边的图块。 : The tile X coordinate in the tiling scheme, where 0 is the Easternmost tile.
  • {reverseY}:切片方案中切片的 Y 坐标,其中 0 是最南端的切片。 : The tile Y coordinate in the tiling scheme, where 0 is the Southernmost tile.
  • {reverseZ}:切片方案中切片的级别,其中级别 0 是四叉树金字塔的最大级别。为了使用reverseZ,必须定义maximumLevel。 : The level of the tile in the tiling scheme, where level zero is the maximum level of the quadtree pyramid. In order to use reverseZ, maximumLevel must be defined.
  • {westDegrees}: The Western edge of the tile in geodetic degrees.
  • {southDegrees}:瓷砖的南边缘(大地测量角度)。 : The Southern edge of the tile in geodetic degrees.
  • {eastDegrees}:以大地度数表示的图块的东部边缘。 : The Eastern edge of the tile in geodetic degrees.
  • {northDegrees}:瓷砖的北边缘(以大地测量角度表示)。 : The Northern edge of the tile in geodetic degrees.
  • {westProjected}: The Western edge of the tile in projected coordinates of the tiling scheme.
  • {southProjected}:切片方案投影坐标中切片的南边缘。 : The Southern edge of the tile in projected coordinates of the tiling scheme.
  • {eastProjected}:切片方案的投影坐标中切片的东边。 : The Eastern edge of the tile in projected coordinates of the tiling scheme.
  • {northProjected}:切片方案投影坐标中切片的北边缘。 : The Northern edge of the tile in projected coordinates of the tiling scheme.
  • {width}:每个图块的宽度(以像素为单位)。 : The width of each tile in pixels.
  • {height}:每个图块的高度(以像素为单位)。 : The height of each tile in pixels.

readonly urlSchemeZeroPadding : object

获取每个图块坐标的 URL 方案零填充。格式为“000”,其中每个坐标将在左侧填充零,以匹配传递的零字符串的宽度。例如设置: urlSchemeZeroPadding: { '{x}': '0000'} 将导致 'x' 值 12 在生成的 URL 中为 {x} 返回字符串 '0012'。它有以下关键词: Gets the URL scheme zero padding for each tile coordinate. The format is '000' where each coordinate will be padded on the left with zeros to match the width of the passed string of zeros. e.g. Setting: urlSchemeZeroPadding : { '{x}' : '0000'} will cause an 'x' value of 12 to return the string '0012' for {x} in the generated URL. It has the following keywords:
  • {z}: The zero padding for the level of the tile in the tiling scheme.
  • {x}:切片方案中切片 X 坐标的零填充。 : The zero padding for the tile X coordinate in the tiling scheme.
  • {y}:切片方案中切片 Y 坐标的零填充。 : The zero padding for the the tile Y coordinate in the tiling scheme.
  • {reverseX}:切片方案中切片反向X 坐标的零填充。 : The zero padding for the tile reverseX coordinate in the tiling scheme.
  • {reverseY}:切片方案中切片反向Y 坐标的零填充。 : The zero padding for the tile reverseY coordinate in the tiling scheme.
  • {reverseZ}: The zero padding for the reverseZ coordinate of the tile in the tiling scheme.

方法 Methods

getTileCredits(x, y, level)Array.<Credit>

获取显示给定图块时要显示的积分。 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. It may also be undefined if picking is not supported.

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

名称 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.UrlTemplateImageryProvider.ConstructorOptions

UrlTemplateImageryProvider 构造函数的初始化选项 Initialization options for the UrlTemplateImageryProvider constructor
属性: Properties:
名称 Name 类型 Type Attributes 默认值 Default 说明 Description
url Resource | string 用于请求图块的 URL 模板。它有以下关键词: The URL template to use to request tiles. It has the following keywords:
  • {z}: The level of the tile in the tiling scheme. Level zero is the root of the quadtree pyramid.
  • {x}:切片方案中切片的 X 坐标,其中 0 是最西边的切片。 : The tile X coordinate in the tiling scheme, where 0 is the Westernmost tile.
  • {y}:切片方案中切片的 Y 坐标,其中 0 是最北的切片。 : The tile Y coordinate in the tiling scheme, where 0 is the Northernmost tile.
  • {s}:可用子域之一,用于克服浏览器对每个主机同时请求数量的限制。 : One of the available subdomains, used to overcome browser limits on the number of simultaneous requests per host.
  • {reverseX}:切片方案中图块的 X 坐标,其中 0 是最东边的图块。 : The tile X coordinate in the tiling scheme, where 0 is the Easternmost tile.
  • {reverseY}:切片方案中切片的 Y 坐标,其中 0 是最南端的切片。 : The tile Y coordinate in the tiling scheme, where 0 is the Southernmost tile.
  • {reverseZ}:切片方案中切片的级别,其中级别 0 是四叉树金字塔的最大级别。为了使用reverseZ,必须定义maximumLevel。 : The level of the tile in the tiling scheme, where level zero is the maximum level of the quadtree pyramid. In order to use reverseZ, maximumLevel must be defined.
  • {westDegrees}: The Western edge of the tile in geodetic degrees.
  • {southDegrees}:瓷砖的南边缘(大地测量角度)。 : The Southern edge of the tile in geodetic degrees.
  • {eastDegrees}:以大地度数表示的图块的东部边缘。 : The Eastern edge of the tile in geodetic degrees.
  • {northDegrees}:瓷砖的北边缘(以大地测量角度表示)。 : The Northern edge of the tile in geodetic degrees.
  • {westProjected}: The Western edge of the tile in projected coordinates of the tiling scheme.
  • {southProjected}:切片方案投影坐标中切片的南边缘。 : The Southern edge of the tile in projected coordinates of the tiling scheme.
  • {eastProjected}:切片方案的投影坐标中切片的东边。 : The Eastern edge of the tile in projected coordinates of the tiling scheme.
  • {northProjected}:切片方案投影坐标中切片的北边缘。 : The Northern edge of the tile in projected coordinates of the tiling scheme.
  • {width}:每个图块的宽度(以像素为单位)。 : The width of each tile in pixels.
  • {height}:每个图块的高度(以像素为单位)。 : The height of each tile in pixels.
pickFeaturesUrl Resource | string <可选> &lt;optional>
用于选择功能的 URL 模板。如果未指定此属性, The URL template to use to pick features. If this property is not specified, UrlTemplateImageryProvider#pickFeatures 将立即返回未定义,表示没有选择任何功能。 URL 模板支持所有受支持的关键字 will immediately returned undefined, indicating no features picked. The URL template supports all of the keywords supported by the url 参数,加上以下内容: parameter, plus the following:
  • {i}:拾取位置的像素列(水平坐标),最西边的像素为0。 : The pixel column (horizontal coordinate) of the picked position, where the Westernmost pixel is 0.
  • {j}:拾取位置的像素行(垂直坐标),其中最北像素为 0。 : The pixel row (vertical coordinate) of the picked position, where the Northernmost pixel is 0.
  • {reverseI}:拾取位置的像素列(水平坐标),其中最东边的像素为0。 : The pixel column (horizontal coordinate) of the picked position, where the Easternmost pixel is 0.
  • {reverseJ}:拾取位置的像素行(垂直坐标),其中最南端的像素为 0。 : The pixel row (vertical coordinate) of the picked position, where the Southernmost pixel is 0.
  • {longitudeDegrees}:所选位置的经度(以度为单位)。 : The longitude of the picked position in degrees.
  • {latitudeDegrees}:所选位置的纬度(以度为单位)。 : The latitude of the picked position in degrees.
  • {longitudeProjected}:切片方案投影坐标中选取位置的经度。 : The longitude of the picked position in the projected coordinates of the tiling scheme.
  • {latitudeProjected}:切片方案投影坐标中选取位置的纬度。 : The latitude of the picked position in the projected coordinates of the tiling scheme.
  • {format}:获取特征信息的格式,如 : The format in which to get feature information, as specified in the GetFeatureInfoFormat.
urlSchemeZeroPadding object <可选> &lt;optional>
获取每个图块坐标的 URL 方案零填充。格式为“000”,其中每个坐标将在左侧填充零,以匹配传递的零字符串的宽度。例如设置: urlSchemeZeroPadding: { '{x}': '0000'} 将导致 'x' 值 12 在生成的 URL 中为 {x} 返回字符串 '0012'。如果传递的对象具有以下关键字: Gets the URL scheme zero padding for each tile coordinate. The format is '000' where each coordinate will be padded on the left with zeros to match the width of the passed string of zeros. e.g. Setting: urlSchemeZeroPadding : { '{x}' : '0000'} will cause an 'x' value of 12 to return the string '0012' for {x} in the generated URL. It the passed object has the following keywords:
  • {z}: The zero padding for the level of the tile in the tiling scheme.
  • {x}:切片方案中切片 X 坐标的零填充。 : The zero padding for the tile X coordinate in the tiling scheme.
  • {y}:切片方案中切片 Y 坐标的零填充。 : The zero padding for the the tile Y coordinate in the tiling scheme.
  • {reverseX}:切片方案中切片反向X 坐标的零填充。 : The zero padding for the tile reverseX coordinate in the tiling scheme.
  • {reverseY}:切片方案中切片反向Y 坐标的零填充。 : The zero padding for the tile reverseY coordinate in the tiling scheme.
  • {reverseZ}: The zero padding for the reverseZ coordinate of the tile in the tiling scheme.
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.
credit Credit | string <可选> &lt;optional>
'' 数据源的来源,显示在画布上。 A credit for the data source, which is displayed on the canvas.
minimumLevel number <可选> &lt;optional>
0 图像提供商支持的最低细节级别。指定此选项时请注意,最低级别的图块数量较小,例如四个或更少。数量过多可能会导致渲染问题。 The minimum level-of-detail supported by the imagery provider. Take care when specifying this that the number of tiles at the minimum level is small, such as four or less. A larger number is likely to result in rendering problems.
maximumLevel number <可选> &lt;optional>
图像提供者支持的最大细节级别,如果没有限制则未定义。 The maximum level-of-detail supported by the imagery provider, or undefined if there is no limit.
rectangle Rectangle <可选> &lt;optional>
Rectangle.MAX_VALUE 图像覆盖的矩形(以弧度表示)。 The rectangle, in radians, covered by the image.
tilingScheme TilingScheme <可选> &lt;optional>
WebMercatorTilingScheme 切片方案指定如何将椭圆体表面分解为切片。如果未提供此参数,则 The tiling scheme specifying how the ellipsoidal surface is broken into tiles. If this parameter is not provided, a WebMercatorTilingScheme 被使用。 is used.
ellipsoid Ellipsoid <可选> &lt;optional>
椭球体。如果指定了 tilingScheme,则忽略此参数并使用切片方案的椭球体。如果两个参数均未指定,则使用 WGS84 椭球体。 The ellipsoid. If the tilingScheme is specified, this parameter is ignored and the tiling scheme's ellipsoid is used instead. If neither parameter is specified, the WGS84 ellipsoid is used.
tileWidth number <可选> &lt;optional>
256 图像图块的像素宽度。 Pixel width of image tiles.
tileHeight number <可选> &lt;optional>
256 图像图块的像素高度。 Pixel height of image tiles.
hasAlphaChannel boolean <可选> &lt;optional>
true 如果此图像提供商提供的图像包含 Alpha 通道,则为 true;否则为假。如果此属性为 false,则 Alpha 通道(如果存在)将被忽略。如果此属性为 true,则任何没有 Alpha 通道的图像都将被视为其 Alpha 在任何地方都是 1.0。当此属性为 false 时,内存使用量和纹理上传时间可能会减少。 true if the images provided by this imagery provider include an alpha channel; otherwise, false. 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 potentially reduced.
getFeatureInfoFormats Array.<GetFeatureInfoFormat> <可选> &lt;optional>
获取特定位置要素信息的格式 The formats in which to get feature information at a specific location when UrlTemplateImageryProvider#pickFeatures 被调用。如果未指定此参数,则禁用特征拾取。 is invoked. If this parameter is not specified, feature picking is disabled.
enablePickFeatures boolean <可选> &lt;optional>
true 如果属实的话, If true, UrlTemplateImageryProvider#pickFeatures 将要求 will request the pickFeaturesUrl 并尝试解释响应中包含的功能。如果是假的, and attempt to interpret the features included in the response. If false, UrlTemplateImageryProvider#pickFeatures 将立即返回未定义(表示没有可选择的功能),而不与服务器通信。如果您知道您的数据源不支持选择功能或者您不希望该提供程序的功能可供选择,请将此属性设置为 false。请注意,这可以通过修改来动态覆盖 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. Note that this can be dynamically overridden by modifying the UriTemplateImageryProvider#enablePickFeatures property.
tileDiscardPolicy TileDiscardPolicy <可选> &lt;optional>
根据某些标准丢弃平铺图像的策略 A policy for discarding tile images according to some criteria
customTags object <可选> &lt;optional>
允许替换 URL 模板中的自定义关键字。该对象必须以字符串作为键,以函数作为值。 Allow to replace custom keywords in the URL template. The object must have strings as keys and functions as values.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.