English中文

Resource

new Cesium.Resource(options)

一种资源,包括位置以及我们检索它或创建派生资源所需的任何其他参数。它还提供重试请求的能力。 A resource that includes the location and any other parameters we need to retrieve it or create derived resources. It also provides the ability to retry requests.
名称 Name 类型 Type 说明 Description
options string | Resource.ConstructorOptions 描述初始化选项的 url 或对象 A url or an object describing initialization options
示例: Example:
function refreshTokenRetryCallback(resource, error) {
  if (error.statusCode === 403) {
    // 403 status code means a new token should be generated
    return getNewAccessToken()
      .then(function(token) {
        resource.queryParameters.access_token = token;
        return true;
      })
      .catch(function() {
        return false;
      });
  }

  return false;
}

const resource = new Resource({
   url: 'http://server.com/path/to/resource.json',
   proxy: new DefaultProxy('/proxy/'),
   headers: {
     'X-My-Header': 'valueOfHeader'
   },
   queryParameters: {
     'access_token': '123-435-456-000'
   },
   retryCallback: refreshTokenRetryCallback,
   retryAttempts: 1
});

成员 Members

static constant Cesium.Resource.DEFAULT : Resource

初始化为当前浏览器位置的资源实例 A resource instance initialized to the current browser location

static readonly Cesium.Resource.isBlobSupported : boolean

如果支持 blob,则返回 true。 Returns true if blobs are supported.

readonly extension : string

资源的文件扩展名。 The file extension of the resource.

hasHeaders : boolean

如果资源具有请求标头,则为 True。这相当于检查 headers 属性是否有任何键。 True if the Resource has request headers. This is equivalent to checking if the headers property has any keys.
将随请求发送的附加 HTTP 标头。 Additional HTTP headers that will be sent with the request.
如果资源引用 blob URI,则为 true。 True if the Resource refers to a blob URI.

isCrossOriginUrl : boolean

如果资源引用跨源 URL,则为 true。 True if the Resource refers to a cross origin URL.
如果资源引用数据 URI,则为 True。 True if the Resource refers to a data URI.
加载资源时要使用的代理。 A proxy to be used when loading the resource.

readonly queryParameters : object

附加到 url 的查询参数。 Query parameters appended to the url.
将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.

retryAttempts : number

放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.

retryCallback : function

对此资源的请求失败时调用的函数。如果它返回 true 或解析为 true 的 Promise,则将重试该请求。 Function to call when a request for this resource fails. If it returns true or a Promise that resolves to true, the request will be retried.

readonly templateValues : object

用于替换 url 中模板参数的键/值对。 The key/value pairs used to replace template parameters in the url.
资源的 url,其中替换了模板值,附加了查询字符串,并由代理编码(如果已设置)。 The url to the resource with template values replaced, query string appended and encoded by proxy if one was set.

方法 Methods

static Cesium.Resource.delete(options)Promise.<any>|undefined

从 URL 创建资源并对其调用 delete()。 Creates a Resource from a URL and calls delete() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
data object 可选 optional 随资源发布的数据。 Data that is posted with the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.fetch(options)Promise.<any>|undefined

从 URL 创建资源并对其调用 fetch()。 Creates a Resource from a URL and calls fetch() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.fetchArrayBuffer(options)Promise.<ArrayBuffer>|undefined

创建一个 Resource 并对其调用 fetchArrayBuffer()。 Creates a Resource and calls fetchArrayBuffer() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.fetchBlob(options)Promise.<Blob>|undefined

创建一个 Resource 并对其调用 fetchBlob()。 Creates a Resource and calls fetchBlob() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.fetchImage(options)Promise.<(ImageBitmap|HTMLImageElement)>|undefined

创建一个 Resource 并对其调用 fetchImage()。 Creates a Resource and calls fetchImage() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
flipY boolean false 可选 optional 获取和解码过程中是否垂直翻转图像。仅在请求图像且浏览器支持时适用 Whether to vertically flip the image during fetch and decode. Only applies when requesting an image and the browser supports createImageBitmap.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
preferBlob boolean false 可选 optional 如果为 true,我们将通过 blob 加载图像。 If true, we will load the image via a blob.
preferImageBitmap boolean false 可选 optional 如果为 true,则图像将在获取期间被解码,并且 If true, image will be decoded during fetch and an ImageBitmap 被返回。 is returned.
skipColorSpaceConversion boolean false 可选 optional 如果为 true,则图像中的任何自定义伽马或颜色配置文件都将被忽略。仅在请求图像且浏览器支持时适用 If true, any custom gamma or color profiles in the image will be ignored. Only applies when requesting an image and the browser supports createImageBitmap.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.fetchJson(options)Promise.<any>|undefined

创建一个 Resource 并对其调用 fetchJson()。 Creates a Resource and calls fetchJson() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.fetchJsonp(options)Promise.<any>|undefined

从 URL 创建资源并对其调用 fetchJsonp()。 Creates a Resource from a URL and calls fetchJsonp() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
callbackParameterName string 'callback' 可选 optional 服务器期望的回调参数名称。 The callback parameter name that the server expects.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.fetchText(options)Promise.<string>|undefined

创建一个资源并对其调用 fetchText()。 Creates a Resource and calls fetchText() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.fetchXML(options)Promise.<XMLDocument>|undefined

创建一个资源并对其调用 fetchXML()。 Creates a Resource and calls fetchXML() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.head(options)Promise.<any>|undefined

从 URL 创建资源并对其调用 head()。 Creates a Resource from a URL and calls head() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.options(options)Promise.<any>|undefined

从 URL 创建资源并对其调用 options()。 Creates a Resource from a URL and calls options() on it.
名称 Name 类型 Type 说明 Description
options string | object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.patch(options)Promise.<any>|undefined

从 URL 创建资源并对其调用 patch()。 Creates a Resource from a URL and calls patch() on it.
名称 Name 类型 Type 说明 Description
options object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
data object 随资源发布的数据。 Data that is posted with the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.post(options)Promise.<any>|undefined

从 URL 创建资源并对其调用 post()。 Creates a Resource from a URL and calls post() on it.
名称 Name 类型 Type 说明 Description
options object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
data object 随资源发布的数据。 Data that is posted with the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

static Cesium.Resource.put(options)Promise.<any>|undefined

从 URL 创建资源并对其调用 put()。 Creates a Resource from a URL and calls put() on it.
名称 Name 类型 Type 说明 Description
options object 具有以下属性的 url 或对象 A url or an object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
data object 随资源发布的数据。 Data that is posted with the resource.
queryParameters object 可选 optional 包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number 0 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.

appendForwardSlash()

将正斜杠附加到 URL。 Appends a forward slash to the URL.

appendQueryParameters(params)

组合指定的对象和现有的查询参数。这允许您一次添加多个参数,而不是一次将一个参数添加到 queryParameters 属性。 Combines the specified object and the existing query parameters. This allows you to add many parameters at once, as opposed to adding them one at a time to the queryParameters property.
名称 Name 类型 Type 说明 Description
params object 查询参数 The query parameters
Duplicates a Resource instance.
名称 Name 类型 Type 说明 Description
result Resource 可选 optional 用于存储结果的对象。 The object onto which to store the result.
返回: Returns:
修改后的结果参数或新的资源实例(如果未提供)。 The modified result parameter or a new Resource instance if one was not provided.

delete(options)Promise.<any>|undefined

异步删除给定资源。返回一个承诺,该承诺将在加载后解决结果,或者如果资源加载失败则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously deletes the given resource. Returns a promise that will resolve to the result once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 说明 Description
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
headers object 可选 optional 与请求一起发送的其他 HTTP 标头(如果有)。 Additional HTTP headers to send with the request, if any.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
resource.delete()
  .then(function(body) {
      // use the data
  }).catch(function(error) {
      // an error occurred
  });
另见: See:

fetch(options)Promise.<any>|undefined

异步加载给定资源。返回一个承诺,该承诺将在加载后解决结果,或者如果资源加载失败则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。建议您使用更具体的功能,例如。 fetchJson、fetchBlob 等 Asynchronously loads the given resource. Returns a promise that will resolve to the result once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled. It's recommended that you use the more specific functions eg. fetchJson, fetchBlob, etc.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 说明 Description
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
headers object 可选 optional 与请求一起发送的其他 HTTP 标头(如果有)。 Additional HTTP headers to send with the request, if any.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
resource.fetch()
  .then(function(body) {
      // use the data
  }).catch(function(error) {
      // an error occurred
  });
另见: See:

fetchArrayBuffer()Promise.<ArrayBuffer>|undefined

将资源作为原始二进制数据异步加载。返回一个承诺,一旦加载,该承诺将解析为 ArrayBuffer;如果资源加载失败,则返回一个拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously loads the resource as raw binary data. Returns a promise that will resolve to an ArrayBuffer once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
// load a single URL asynchronously
resource.fetchArrayBuffer().then(function(arrayBuffer) {
    // use the data
}).catch(function(error) {
    // an error occurred
});
另见: See:

fetchBlob()Promise.<Blob>|undefined

将给定资源作为 blob 异步加载。返回一个承诺,一旦加载,该承诺将解析为 Blob;如果资源加载失败,则返回拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously loads the given resource as a blob. Returns a promise that will resolve to a Blob once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
// load a single URL asynchronously
resource.fetchBlob().then(function(blob) {
    // use the data
}).catch(function(error) {
    // an error occurred
});
另见: See:

fetchImage(options)Promise.<(ImageBitmap|HTMLImageElement)>|undefined

异步加载给定的图像资源。返回一个将解决的承诺 Asynchronously loads the given image resource. Returns a promise that will resolve to an ImageBitmap if preferImageBitmap 是 true 并且浏览器支持 is true and the browser supports createImageBitmap 或以其他方式 or otherwise an Image 一旦加载,或者如果图像加载失败则拒绝。 once loaded, or reject if the image failed to load.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象。 An object with the following properties.
名称 Name 类型 Type 默认值 Default 说明 Description
preferBlob boolean false 可选 optional 如果为 true,我们将通过 blob 加载图像。 If true, we will load the image via a blob.
preferImageBitmap boolean false 可选 optional 如果为 true,则图像将在获取期间被解码,并且 If true, image will be decoded during fetch and an ImageBitmap 被返回。 is returned.
flipY boolean false 可选 optional 如果为 true,则图像将在解码期间垂直翻转。仅当浏览器支持时才适用 If true, image will be vertically flipped during decode. Only applies if the browser supports createImageBitmap.
skipColorSpaceConversion boolean false 可选 optional 如果为 true,则图像中的任何自定义伽马或颜色配置文件都将被忽略。仅当浏览器支持时才适用 If true, any custom gamma or color profiles in the image will be ignored. Only applies if the browser supports createImageBitmap.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
// load a single image asynchronously
resource.fetchImage().then(function(image) {
    // use the loaded image
}).catch(function(error) {
    // an error occurred
});

// load several images in parallel
Promise.all([resource1.fetchImage(), resource2.fetchImage()]).then(function(images) {
    // images is an array containing all the loaded images
});
另见: See:

fetchJson()Promise.<any>|undefined

以 JSON 形式异步加载给定资源。返回一个承诺,一旦加载,该承诺将解析为 JSON 对象,如果资源加载失败,则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。如果尚未指定,此函数会将“Accept: application/json,*/*;q=0.01”添加到请求标头中。 Asynchronously loads the given resource as JSON. Returns a promise that will resolve to a JSON object once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled. This function adds 'Accept: application/json,&#42;&#47;&#42;;q=0.01' to the request headers, if not already specified.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
resource.fetchJson().then(function(jsonData) {
    // Do something with the JSON object
}).catch(function(error) {
    // an error occurred
});
另见: See:

fetchJsonp(callbackParameterName)Promise.<any>|undefined

使用 JSONP 请求资源。 Requests a resource using JSONP.
名称 Name 类型 Type 默认值 Default 说明 Description
callbackParameterName string 'callback' 可选 optional 服务器期望的回调参数名称。 The callback parameter name that the server expects.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
// load a data asynchronously
resource.fetchJsonp().then(function(data) {
    // use the loaded data
}).catch(function(error) {
    // an error occurred
});
另见: See:

fetchText()Promise.<string>|undefined

以文本形式异步加载给定资源。返回一个承诺,一旦加载,该承诺将解析为字符串,如果资源加载失败,则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously loads the given resource as text. Returns a promise that will resolve to a String once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
// load text from a URL, setting a custom header
const resource = new Resource({
  url: 'http://someUrl.com/someJson.txt',
  headers: {
    'X-Custom-Header' : 'some value'
  }
});
resource.fetchText().then(function(text) {
    // Do something with the text
}).catch(function(error) {
    // an error occurred
});
另见: See:

fetchXML()Promise.<XMLDocument>|undefined

以 XML 形式异步加载给定资源。返回一个承诺,一旦加载,该承诺将解析为 XML 文档,如果资源加载失败,则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously loads the given resource as XML. Returns a promise that will resolve to an XML Document once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
// load XML from a URL, setting a custom header
Cesium.loadXML('http://someUrl.com/someXML.xml', {
  'X-Custom-Header' : 'some value'
}).then(function(document) {
    // Do something with the document
}).catch(function(error) {
    // an error occurred
});
另见: See:

getBaseUri(includeQuery)string

返回资源的基本路径。 Returns the base path of the Resource.
名称 Name 类型 Type 默认值 Default 说明 Description
includeQuery boolean false 可选 optional 是否包含 uri 中的查询字符串和片段 Whether or not to include the query string and fragment form the uri
返回: Returns:
资源的基本 URI The base URI of the resource

getDerivedResource(options)Resource

返回相对于当前实例的资源。除非在选项中覆盖,否则所有属性都与当前实例相同。 Returns a resource relative to the current instance. All properties remain the same as the current instance unless overridden in options.
名称 Name 类型 Type 说明 Description
options object 具有以下属性的对象 An object with the following properties
名称 Name 类型 Type 默认值 Default 说明 Description
url string 可选 optional 将相对于当前实例的 url 进行解析的 url。 The url that will be resolved relative to the url of the current instance.
queryParameters object 可选 optional 包含查询参数的对象,这些参数将与当前实例的查询参数相结合。 An object containing query parameters that will be combined with those of the current instance.
templateValues object 可选 optional 用于替换模板值的键/值对(例如 {x})。这些将与当前实例的那些相结合。 Key/Value pairs that are used to replace template values (eg. {x}). These will be combined with those of the current instance.
headers object {} 可选 optional 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy 可选 optional 加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback 可选 optional 加载资源失败时调用的函数。 The function to call when loading the resource fails.
retryAttempts number 可选 optional 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request 可选 optional 将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
preserveQueryParameters boolean false 可选 optional 如果为 true,这将保留当前资源和派生资源中的所有查询参数。如果为 false,派生参数将替换当前资源的参数。 If true, this will keep all query parameters from the current resource and derived resource. If false, derived parameters will replace those of the current resource.
返回: Returns:
从当前资源派生的资源。 The resource derived from the current one.

getUrlComponent(query, proxy)string

返回 url,可选带有查询字符串并由代理处理。 Returns the url, optional with the query string and processed by a proxy.
名称 Name 类型 Type 默认值 Default 说明 Description
query boolean false 可选 optional 如果为 true,则包含查询字符串。 If true, the query string is included.
proxy boolean false 可选 optional 如果为 true,则 url 将由代理对象(如果已定义)处理。 If true, the url is processed by the proxy object, if defined.
返回: Returns:
包含所有请求组件的 url。 The url with all the requested components.
异步获取给定资源的标头。返回一个承诺,该承诺将在加载后解决结果,或者如果资源加载失败则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously gets headers the given resource. Returns a promise that will resolve to the result once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 说明 Description
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
headers object 可选 optional 与请求一起发送的其他 HTTP 标头(如果有)。 Additional HTTP headers to send with the request, if any.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
resource.head()
  .then(function(headers) {
      // use the data
  }).catch(function(error) {
      // an error occurred
  });
另见: See:

options(options)Promise.<any>|undefined

异步获取给定资源的选项。返回一个承诺,该承诺将在加载后解决结果,或者如果资源加载失败则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously gets options the given resource. Returns a promise that will resolve to the result once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 说明 Description
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
headers object 可选 optional 与请求一起发送的其他 HTTP 标头(如果有)。 Additional HTTP headers to send with the request, if any.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
resource.options()
  .then(function(headers) {
      // use the data
  }).catch(function(error) {
      // an error occurred
  });
另见: See:

patch(data, options)Promise.<any>|undefined

将数据异步修补到给定资源。返回一个承诺,该承诺将在加载后解决结果,或者如果资源加载失败则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously patches data to the given resource. Returns a promise that will resolve to the result once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
名称 Name 类型 Type 说明 Description
data object 随资源发布的数据。 Data that is posted with the resource.
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 说明 Description
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
headers object 可选 optional 与请求一起发送的其他 HTTP 标头(如果有)。 Additional HTTP headers to send with the request, if any.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
resource.patch(data)
  .then(function(result) {
      // use the result
  }).catch(function(error) {
      // an error occurred
  });
另见: See:

post(data, options)Promise.<any>|undefined

将数据异步发布到给定资源。返回一个承诺,该承诺将在加载后解决结果,或者如果资源加载失败则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously posts data to the given resource. Returns a promise that will resolve to the result once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
名称 Name 类型 Type 说明 Description
data object 随资源发布的数据。 Data that is posted with the resource.
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 说明 Description
data object 可选 optional 随资源发布的数据。 Data that is posted with the resource.
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
headers object 可选 optional 与请求一起发送的其他 HTTP 标头(如果有)。 Additional HTTP headers to send with the request, if any.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
resource.post(data)
  .then(function(result) {
      // use the result
  }).catch(function(error) {
      // an error occurred
  });
另见: See:

put(data, options)Promise.<any>|undefined

异步将数据放入给定资源。返回一个承诺,该承诺将在加载后解决结果,或者如果资源加载失败则拒绝。数据使用 XMLHttpRequest 加载,这意味着为了向另一个源发出请求,服务器必须启用跨源资源共享 (CORS) 标头。 Asynchronously puts data to the given resource. Returns a promise that will resolve to the result once loaded, or reject if the resource failed to load. The data is loaded using XMLHttpRequest, which means that in order to make requests to another origin, the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
名称 Name 类型 Type 说明 Description
data object 随资源发布的数据。 Data that is posted with the resource.
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 说明 Description
responseType string 可选 optional 响应类型。这控制返回的项目的类型。 The type of response. This controls the type of item returned.
headers object 可选 optional 与请求一起发送的其他 HTTP 标头(如果有)。 Additional HTTP headers to send with the request, if any.
overrideMimeType string 可选 optional 覆盖服务器返回的 MIME 类型。 Overrides the MIME type returned by the server.
返回: Returns:
加载时将解析为请求的数据的承诺。 Returns undefined if a promise that will resolve to the requested data when loaded. Returns undefined if request.throttle 为 true,并且该请求没有足够高的优先级。 is true and the request does not have high enough priority.
示例: Example:
resource.put(data)
  .then(function(result) {
      // use the result
  }).catch(function(error) {
      // an error occurred
  });
另见: See:

setQueryParameters(params, useAsDefault)

组合指定的对象和现有的查询参数。这允许您一次添加多个参数,而不是一次将一个参数添加到 queryParameters 属性。如果已经设置了一个值,它将被新值替换。 Combines the specified object and the existing query parameters. This allows you to add many parameters at once, as opposed to adding them one at a time to the queryParameters property. If a value is already set, it will be replaced with the new value.
名称 Name 类型 Type 默认值 Default 说明 Description
params object 查询参数 The query parameters
useAsDefault boolean false 可选 optional 如果为 true,则参数将用作默认值,因此只有在未定义时才会设置它们。 If true the params will be used as the default values, so they will only be set if they are undefined.

setTemplateValues(template, useAsDefault)

组合指定的对象和现有模板值。这允许您一次添加多个值,而不是一次将它们添加到 templateValues 属性中。如果已经设置了一个值,它将成为一个数组,并附加新值。 Combines the specified object and the existing template values. This allows you to add many values at once, as opposed to adding them one at a time to the templateValues property. If a value is already set, it will become an array and the new value will be appended.
名称 Name 类型 Type 默认值 Default 说明 Description
template object 模板值 The template values
useAsDefault boolean false 可选 optional 如果为 true,这些值将用作默认值,因此只有在未定义时才会设置它们。 If true the values will be used as the default values, so they will only be set if they are undefined.

toString()string

重写 Object#toString 以便隐式字符串转换给出此资源表示的完整 URL。 Override Object#toString so that implicit string conversion gives the complete URL represented by this Resource.
返回: Returns:
该资源表示的 URL The URL represented by this Resource

类型定义 Type Definitions

Cesium.Resource.ConstructorOptions

Resource 构造函数的初始化选项 Initialization options for the Resource constructor
属性: Properties:
名称 Name 类型 Type Attributes 默认值 Default 说明 Description
url string 资源的网址。 The url of the resource.
queryParameters object <可选> &lt;optional>
包含检索资源时将发送的查询参数的对象。 An object containing query parameters that will be sent when retrieving the resource.
templateValues object <可选> &lt;optional>
用于替换模板值的键/值对(例如 {x})。 Key/Value pairs that are used to replace template values (eg. {x}).
headers object <可选> &lt;optional>
{} 将发送的附加 HTTP 标头。 Additional HTTP headers that will be sent.
proxy Proxy <可选> &lt;optional>
加载资源时要使用的代理。 A proxy to be used when loading the resource.
retryCallback Resource.RetryCallback <可选> &lt;optional>
请求该资源失败时调用的函数。如果返回 true,则将重试该请求。 The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts number <可选> &lt;optional>
0 放弃之前应调用 retryCallback 的次数。 The number of times the retryCallback should be called before giving up.
request Request <可选> &lt;optional>
将使用的 Request 对象。仅供内部使用。 A Request object that will be used. Intended for internal use only.
parseUrl boolean <可选> &lt;optional>
true 如果为true,则解析url中的查询参数;否则存储 url 而不做任何更改 If true, parse the url for query parameters; otherwise store the url without change

Cesium.Resource.RetryCallback(resource, error)boolean|Promise.<boolean>

返回属性值的函数。 A function that returns the value of the property.
名称 Name 类型 Type 说明 Description
resource Resource 可选 optional 加载失败的资源。 The resource that failed to load.
error RequestErrorEvent 可选 optional 资源加载过程中发生的错误。 The error that occurred during the loading of the resource.
返回: Returns:
如果为 true 或承诺解析为 true,则将重试该资源。否则会返回失败。 If true or a promise that resolved to true, the resource will be retried. Otherwise the failure will be returned.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.