new Cesium.Resource(options)

包括位置和我们需要的任何其他参数的资源,以获取或创建衍生资源。 它还提供了重试请求的能力.
Name Type Description
options string | Resource.ConstructorOptions Url 或描述初始化选项的对象
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

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

static readonly Cesium.Resource.isBlobSupported : boolean

如果支持blobs,则返回真值 .

readonly extension : string

资源的文件扩展名 .

hasHeaders : boolean

如果资源有请求信头, 则为真 。 这相当于检查信头属性是否有密钥 .

headers : object

Additional HTTP headers that will be sent with the request.

isBlobUri : boolean

True if the Resource refers to a blob URI.

isCrossOriginUrl : boolean

如果资源指的是一个交叉来源 URL .

isDataUri : boolean

True if the Resource refers to a data URI.

proxy : Proxy

装入资源时要使用的代理 .

readonly queryParameters : object

Url 所附查询参数.

request : Request

将使用的请求对象。 仅供内部使用.

retryAttempts : number

重试Callback在放弃前应该呼叫的次数.

retryCallback : function

当请求此资源失败时调用函数 。 如果它返回真,或者一个 Promise 确定为真,则请求会被重审.

readonly templateValues : object

URL中用于替换模板参数的密钥/值对.

url : string

使用模板值替换的 URL 到资源, 查询字符串 附加, 如果设置了 .

Methods

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

Creates a Resource from a URL and calls delete() on it.
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 Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
responseType string optional 反应类型. 此控制返回的项目类型 .
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

Creates a Resource from a URL and calls fetch() on it.
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
responseType string optional 反应类型. 此控制返回的项目类型 .
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

创建资源并调用其中的抓取ArrayBuffer () .
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

创建资源并调用其中的获取Blob( ) .
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

Creates a Resource and calls fetchImage() on it.
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
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 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
preferBlob boolean false optional If true, we will load the image via a blob.
preferImageBitmap boolean false optional If true, image will be decoded during fetch and an ImageBitmap is returned.
skipColorSpaceConversion boolean false optional 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:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

创建资源并调用 Json () .
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

Creates a Resource from a URL and calls fetchJsonp() on it.
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
callbackParameterName string '召回' optional 服务器所期望的召回参数名称 .
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

创建资源, 并调用其中的获取Text( ) .
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

在其上创建资源并调用获取 XML () .
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

Creates a Resource from a URL and calls head() on it.
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
responseType string optional 反应类型. 此控制返回的项目类型 .
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

Creates a Resource from a URL and calls options() on it.
Name Type Description
options string | object Url 或具有以下属性的对象
Name Type Default Description
url string 资源url.
queryParameters object optional 包含查询参数的对象,在检索资源时会发送.
templateValues object optional 用于替换模板值的密钥/值对(如 {x} ).
headers object {} optional Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
responseType string optional 反应类型. 此控制返回的项目类型 .
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

Creates a Resource from a URL and calls patch() on it.
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 Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
responseType string optional 反应类型. 此控制返回的项目类型 .
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

Creates a Resource from a URL and calls post() on it.
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 Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
responseType string optional 反应类型. 此控制返回的项目类型 .
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

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

Creates a Resource from a URL and calls put() on it.
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 Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number 0 optional The number of times the retryCallback should be called before giving up.
request Request optional 将使用的请求对象。 仅供内部使用.
responseType string optional 反应类型. 此控制返回的项目类型 .
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .

appendForwardSlash()

Appends a forward slash to the URL.

appendQueryParameters(params)

合并指定的对象和现有的查询参数。 这使得您可以同时添加许多参数, 而不是在查询Parameters 属性中一次添加一个.
Name Type Description
params object 查询参数

clone(result)Resource

复制资源实例.
Name Type Description
result Resource optional 存储结果的对象 .
Returns:
未提供修改的结果参数或新资源实例 .

delete(options)Promise.<any>|undefined

同步删除给定的资源。 返回一个承诺,决心 生成结果,或者如果资源未加载,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Name Type Description
options object optional 下列属性的对象 :
Name Type Description
responseType string optional 反应类型. 此控制返回的项目类型 .
headers object optional Additional HTTP headers to send with the request, if any.
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
Example:
resource.delete()
  .then(function(body) {
      // use the data
  }).catch(function(error) {
      // an error occurred
  });
See:

fetch(options)Promise.<any>|undefined

同步加载给定资源 。 返回一个承诺,决心 生成结果,或者如果资源未加载,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 。 建议您使用 更具体的函数,例如抓Json、抓Blob等.
Name Type Description
options object optional 下列属性的对象 :
Name Type Description
responseType string optional 反应类型. 此控制返回的项目类型 .
headers object optional Additional HTTP headers to send with the request, if any.
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
Example:
resource.fetch()
  .then(function(body) {
      // use the data
  }).catch(function(error) {
      // an error occurred
  });
See:

fetchArrayBuffer()Promise.<ArrayBuffer>|undefined

同步加载资源为原始二进制数据. 返回一个承诺,决心 a 矩阵缓冲器已装入,如果资源未装入,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
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 。 返回一个承诺,决心 a Blob 已装入,如果资源未装入,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
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

同步加载给定的图像资源 。 返回一个承诺,决心 an ImageBitmap if preferImageBitmap 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 具有下列属性的对象.
Name Type Default Description
preferBlob boolean false optional If true, we will load the image via a blob.
preferImageBitmap boolean false optional If true, image will be decoded during fetch and an ImageBitmap is returned.
flipY boolean false optional If true, image will be vertically flipped during decode. Only applies if the browser supports createImageBitmap.
skipColorSpaceConversion boolean false optional If true, any custom gamma or color profiles in the image will be ignored. Only applies if the browser supports createImageBitmap.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
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 . 返回承诺,决心 a JSON object once loaded, or reject if the resource failed to load. The data is loaded 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, the server must have Cross-Origin Resource Sharing (CORS) headers enabled. This function adds 'Accept: application/json,*/*;q=0.01' to the request headers, if not already specified.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
Example:
resource.fetchJson().then(function(jsonData) {
    // Do something with the JSON object
}).catch(function(error) {
    // an error occurred
});
See:

fetchJsonp(callbackParameterName)Promise.<any>|undefined

请使用 NT 0 请求资源 .
Name Type Default Description
callbackParameterName string '召回' optional 服务器所期望的召回参数名称 .
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
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

同步加载给定的资源为文本 。 返回一个承诺,决心 a 字符串已装入,如果资源未装入,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
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 . 返回承诺,决心 an XML Document once loaded, or reject if the resource failed to load. The data is loaded 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
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

返回资源的基础路径.
Name Type Default Description
includeQuery boolean 虚假 optional 是否包含查询字符串和片段构成uri
Returns:
资源基数 NT% 0

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 Additional HTTP headers that will be sent.
proxy Proxy optional 装入资源时要使用的代理 .
retryCallback Resource.RetryCallback optional 装入资源失败时调用功能 .
retryAttempts number optional 重试Callback在放弃前应该呼叫的次数.
request Request optional 将使用的请求对象。 仅供内部使用.
preserveQueryParameters boolean false optional 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:
资源来源于当前版本.

getUrlComponent(query, proxy)string

返回 URL,可选择的查询字符串,并由代理处理.
Name Type Default Description
query boolean false optional If true, the query string is included.
proxy boolean false optional If true, the url is processed by the proxy object, if defined.
Returns:
包含所有请求组件的url.
同步获得给定的资源头 。 返回一个承诺,决心 生成结果,或者如果资源未加载,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Name Type Description
options object optional 下列属性的对象 :
Name Type Description
responseType string optional 反应类型. 此控制返回的项目类型 .
headers object optional Additional HTTP headers to send with the request, if any.
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
Example:
resource.head()
  .then(function(headers) {
      // use the data
  }).catch(function(error) {
      // an error occurred
  });
See:

options(options)Promise.<any>|undefined

同步获得给定的资源选项 。 返回一个承诺,决心 生成结果,或者如果资源未加载,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Name Type Description
options object optional 下列属性的对象 :
Name Type Description
responseType string optional 反应类型. 此控制返回的项目类型 .
headers object optional Additional HTTP headers to send with the request, if any.
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
Example:
resource.options()
  .then(function(headers) {
      // use the data
  }).catch(function(error) {
      // an error occurred
  });
See:

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

同步补丁给定资源的数据 。 返回一个承诺,决心 生成结果,或者如果资源未加载,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Name Type Description
data object 与资源一起发布的数据 .
options object optional 下列属性的对象 :
Name Type Description
responseType string optional 反应类型. 此控制返回的项目类型 .
headers object optional Additional HTTP headers to send with the request, if any.
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
Example:
resource.patch(data)
  .then(function(result) {
      // use the result
  }).catch(function(error) {
      // an error occurred
  });
See:

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

同步向给定资源发送数据 。 返回一个承诺,决心 生成结果,或者如果资源未加载,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Name Type Description
data object 与资源一起发布的数据 .
options object optional 下列属性的对象 :
Name Type Description
data object optional 与资源一起发布的数据 .
responseType string optional 反应类型. 此控制返回的项目类型 .
headers object optional Additional HTTP headers to send with the request, if any.
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
Example:
resource.post(data)
  .then(function(result) {
      // use the result
  }).catch(function(error) {
      // an error occurred
  });
See:

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

同步将数据输入给定资源 。 返回一个承诺,决心 生成结果,或者如果资源未加载,则拒绝。 数据已装入 使用 XMLHttp 请求,这意味着为了向另一个来源提出请求, 服务器必须启用 Cross-Origin 资源共享( CORS ) 信头 .
Name Type Description
data object 与资源一起发布的数据 .
options object optional 下列属性的对象 :
Name Type Description
responseType string optional 反应类型. 此控制返回的项目类型 .
headers object optional Additional HTTP headers to send with the request, if any.
overrideMimeType string optional Overrides the MIME type returned by the server.
Returns:
承诺在装入时将解决所要求的数据。 如果 NT%% 2 是真的, 且请求没有足够优先级, 返回未定义 .
Example:
resource.put(data)
  .then(function(result) {
      // use the result
  }).catch(function(error) {
      // an error occurred
  });
See:

setQueryParameters(params, useAsDefault)

合并指定的对象和现有的查询参数。 这使得您可以同时添加许多参数, 而不是在查询Parameters 属性中一次添加一个。 如果一个值已经设置, 它将被替换为新值 .
Name Type Default Description
params object 查询参数
useAsDefault boolean false optional If true the params will be used as the default values, so they will only be set if they are undefined.

setTemplateValues(template, useAsDefault)

合并指定的对象和现有的模板值。 这使得您可以同时添加许多值, 而不是将它们一次添加到模板Values属性中。 如果一个值已经设定,它将成为数组,并将附加新的值.
Name Type Default Description
template object 模板值
useAsDefault boolean false optional If true the values will be used as the default values, so they will only be set if they are undefined.

toString()string

覆盖对象 # to String , 以使隐性字符串转换给出 complete URL represented by this Resource.
Returns:
The URL represented by this Resource

Type Definitions

Cesium.Resource.ConstructorOptions

资源构建器的初始化选项
Properties:
Name Type Attributes Default Description
url string 资源url.
queryParameters object <optional>
包含查询参数的对象,在检索资源时会发送.
templateValues object <optional>
用于替换模板值的密钥/值对(如 {x} ).
headers object <optional>
{} Additional HTTP headers that will be sent.
proxy Proxy <optional>
装入资源时要使用的代理 .
retryCallback Resource.RetryCallback <optional>
当请求此资源失败时调用函数 。 如果它返回真实,则请求会被重审.
retryAttempts number <optional>
0 The number of times the retryCallback should be called before giving up.
request Request <optional>
将使用的请求对象。 仅供内部使用.
parseUrl boolean <optional>
true If true, parse the url for query parameters; otherwise store the url without change

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

返回属性值的函数 .
Name Type Description
resource Resource optional 无法装入的资源 .
error RequestErrorEvent optional 资源加载过程中发生的错误 .
Returns:
如果真有或承诺成真,资源将重新审查。 否则失败将被退回.
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.