Resource

new Cesium.Resource(options)

一种资源,它包括检索它或创建派生资源所需的位置和任何其他参数。它还提供了重试请求的能力。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
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;
      })
      .otherwise(function() {
        return false;
      });
  }

  return false;
}

var 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

初始化到当前浏览器位置的资源实例

static readonly Cesium.Resource.isBlobSupported : Boolean

如果支持blob,则返回true。

readonly extension : String

资源的文件扩展名。

hasHeaders : Boolean

如果资源具有请求标头,则为True。这相当于检查headers属性是否有任何键。

headers : Object

将随请求一起发送的其他HTTP标头。

isBlobUri : Boolean

如果资源引用blob URI,则为True。

isCrossOriginUrl : Boolean

如果资源引用跨源URL,则为True。

isDataUri : Boolean

如果资源引用数据URI,则为True。
加载资源时要使用的代理。

readonly queryParameters : Object

附加到url的查询参数。
将使用的请求对象。仅供内部使用。

retryAttempts : Number

放弃前应调用retryCallback的次数。

retryCallback : function

当此资源的请求失败时调用的函数。如果返回true或承诺解析为true,则将重试请求。

readonly templateValues : Object

用于替换url中模板参数的键/值对。

url : String

替换模板值、附加查询字符串并由代理(如果已设置)编码的资源的url。

Methods

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

从URL创建资源并对其调用delete()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
data Object optional 与资源一起过帐的数据。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
responseType String optional 响应的类型。这控制返回的项的类型。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

从URL创建资源并对其调用fetch()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
responseType String optional 响应的类型。这控制返回的项的类型。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

创建资源并对其调用fetchArrayBuffer()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

创建资源并对其调用fetchBlob()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

创建资源并对其调用fetchImage()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
flipY Boolean false optional 在获取和解码期间是否垂直翻转图像。仅适用于请求图像且浏览器支持createImageBitmap时。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
preferBlob Boolean false optional 如果为true,我们将通过blob加载图像。
preferImageBitmap Boolean false optional 如果为true,则在获取期间对图像进行解码,并返回ImageBitmap
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

创建资源并对其调用fetchJson()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

从URL创建资源并对其调用fetchJsonp()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
callbackParameterName String 'callback' optional 服务器需要的回调参数名称。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

创建资源并对其调用fetchText()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

创建资源并对其调用fetchXML()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

从URL创建资源并对其调用head()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
responseType String optional 响应的类型。这控制返回的项的类型。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

从URL创建资源并对其调用options()。
Name Type Description
options String | Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
responseType String optional 响应的类型。这控制返回的项的类型。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

从URL创建资源,并在其上调用patch()。
Name Type Description
options Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
data Object 与资源一起过帐的数据。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
responseType String optional 响应的类型。这控制返回的项的类型。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

从URL创建资源并对其调用post()。
Name Type Description
options Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
data Object 与资源一起过帐的数据。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
responseType String optional 响应的类型。这控制返回的项的类型。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

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

从URL创建资源并对其调用put()。
Name Type Description
options Object 具有以下属性的url或对象
Name Type Default Description
url String 资源的url。
data Object 与资源一起过帐的数据。
queryParameters Object optional 包含检索资源时将发送的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 当对此资源的请求失败时要调用的函数。如果返回true,将重试请求。
retryAttempts Number 0 optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
responseType String optional 响应的类型。这控制返回的项的类型。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。

appendForwardSlash()

向URL追加正斜杠。

appendQueryParameters(params)

组合指定对象和现有查询参数。这允许您一次添加多个参数, 而不是一次一个地将它们添加到queryParameters属性中。
Name Type Description
params Object 查询参数

clone(result)Resource

复制资源实例。
Name Type Description
result Resource optional 要将结果存储到的对象。
Returns:
修改后的结果参数或新的资源实例(如果未提供)。

delete(options)Promise.<*>|undefined

异步删除给定资源。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
resource.delete()
  .then(function(body) {
      // use the data
  }).otherwise(function(error) {
      // an error occurred
  });
See:

fetch(options)Promise.<*>|undefined

异步加载给定资源。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。建议您使用 更具体的函数,如fetchJson、fetchBlob等。
Name Type Description
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
resource.fetch()
  .then(function(body) {
      // use the data
  }).otherwise(function(error) {
      // an error occurred
  });
See:

fetchArrayBuffer()Promise.<ArrayBuffer>|undefined

以原始二进制数据的形式异步加载资源。返回一个承诺 ArrayBuffer一旦加载,或在资源加载失败时拒绝。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
// load a single URL asynchronously
resource.fetchArrayBuffer().then(function(arrayBuffer) {
    // use the data
}).otherwise(function(error) {
    // an error occurred
});
See:

fetchBlob()Promise.<Blob>|undefined

以blob的形式异步加载给定资源。返回一个承诺 一个Blob一旦加载,或者在资源加载失败时拒绝。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
// load a single URL asynchronously
resource.fetchBlob().then(function(blob) {
    // use the data
}).otherwise(function(error) {
    // an error occurred
});
See:

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

异步加载给定的图像资源。返回一个承诺 如果ImageBitmap为真且浏览器支持createImageBitmap或其他 Image一旦加载,或拒绝如果图像加载失败。
Name Type Description
options Object optional 具有以下属性的对象。
Name Type Default Description
preferBlob Boolean false optional 如果为true,我们将通过blob加载图像。
preferImageBitmap Boolean false optional 如果为true,则在获取期间对图像进行解码,并返回ImageBitmap
flipY Boolean false optional 如果为真,则在解码期间图像将垂直翻转。仅适用于浏览器支持createImageBitmap的情况。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
// load a single image asynchronously
resource.fetchImage().then(function(image) {
    // use the loaded image
}).otherwise(function(error) {
    // an error occurred
});

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

fetchJson()Promise.<*>|undefined

以JSON的形式异步加载给定资源。返回一个承诺 JSON对象一旦加载,或者如果资源加载失败则拒绝。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。这个函数 如果没有,则将“Accept:application/json,*/*;q=0.01”添加到请求头中 已经指定。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
resource.fetchJson().then(function(jsonData) {
    // Do something with the JSON object
}).otherwise(function(error) {
    // an error occurred
});
See:

fetchJsonp(callbackParameterName)Promise.<*>|undefined

使用JSONP请求资源。
Name Type Default Description
callbackParameterName String 'callback' optional 服务器需要的回调参数名称。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
// load a data asynchronously
resource.fetchJsonp().then(function(data) {
    // use the loaded data
}).otherwise(function(error) {
    // an error occurred
});
See:

fetchText()Promise.<String>|undefined

以文本的形式异步加载给定资源。返回一个承诺 一个字符串一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
// load text from a URL, setting a custom header
var 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
}).otherwise(function(error) {
    // an error occurred
});
See:

fetchXML()Promise.<XMLDocument>|undefined

以XML的形式异步加载给定资源。返回一个承诺 XML文档一旦加载,或在资源加载失败时拒绝。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
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
}).otherwise(function(error) {
    // an error occurred
});
See:

getBaseUri(includeQuery)String

返回资源的基路径。
Name Type Default Description
includeQuery Boolean false optional 是否包含构成uri的查询字符串和片段
Returns:
资源的基URI

getDerivedResource(options)Resource

返回相对于当前实例的资源。除非在“选项”中重写,否则所有属性都与当前实例相同。
Name Type Description
options Object 具有以下属性的对象
Name Type Default Description
url String optional 将相对于当前实例的url解析的url。
queryParameters Object optional 包含将与当前实例的查询参数组合的查询参数的对象。
templateValues Object optional 用于替换模板值的键/值对(例如{x})。这些将与当前实例的合并。
headers Object {} optional 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 加载资源时要调用的函数失败。
retryAttempts Number optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
preserveQueryParameters Boolean false optional 如果为true,则将保留当前资源和派生资源的所有查询参数。如果为false,则派生参数将替换当前资源的参数。
Returns:
从当前资源派生的资源。

getUrlComponent(query, proxy)String

返回url,可选的查询字符串,并由代理处理。
Name Type Default Description
query Boolean false optional 如果为true,则包含查询字符串。
proxy Boolean false optional 如果为true,则由代理对象(如果已定义)处理url。
Returns:
包含所有请求组件的url。
异步获取给定资源的标头。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
resource.head()
  .then(function(headers) {
      // use the data
  }).otherwise(function(error) {
      // an error occurred
  });
See:

options(options)Promise.<*>|undefined

异步获取给定资源的选项。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
resource.options()
  .then(function(headers) {
      // use the data
  }).otherwise(function(error) {
      // an error occurred
  });
See:

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

异步提供给资源修补程序。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
data Object 与资源一起过帐的数据。
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
resource.patch(data)
  .then(function(result) {
      // use the result
  }).otherwise(function(error) {
      // an error occurred
  });
See:

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

异步地将数据发布到给定的资源。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
data Object 与资源一起过帐的数据。
options Object optional 具有以下属性的对象:
Name Type Description
data Object optional 与资源一起过帐的数据。
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
resource.post(data)
  .then(function(result) {
      // use the result
  }).otherwise(function(error) {
      // an error occurred
  });
See:

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

异步地将数据放入给定资源。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
data Object 与资源一起过帐的数据。
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Example:
resource.put(data)
  .then(function(result) {
      // use the result
  }).otherwise(function(error) {
      // an error occurred
  });
See:

setQueryParameters(params, useAsDefault)

组合指定对象和现有查询参数。这允许您一次添加多个参数, 而不是一次一个地将它们添加到queryParameters属性中。如果已经设置了值,则将用新值替换该值。
Name Type Default Description
params Object 查询参数
useAsDefault Boolean false optional 如果为true,则参数将用作默认值,因此只有在未定义时才会设置这些值。

setTemplateValues(template, useAsDefault)

组合指定对象和现有模板值。这样可以同时添加多个值, 而不是一次一个地将它们添加到templateValues属性中。如果已经设置了一个值,它将成为一个数组,新值将被追加。
Name Type Default Description
template Object 模板值
useAsDefault Boolean false optional 如果为true,则值将用作默认值,因此只有在未定义时才会设置这些值。

toString()String

重写Object#toString,以便隐式字符串转换为 此资源表示的完整URL。
Returns:
此资源表示的URL

Type Definitions

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

返回属性值的函数。
Name Type Description
resource Resource optional 未能加载的资源。
error Error optional 加载资源期间发生的错误。
Returns:
如果为true或某个承诺解析为true,则将重试资源。否则将返回失败。