new Cesium.IonResource(endpoint, endpointResource)

A Resource instance that encapsulates Cesium ion asset access. 此天体通常不直接即时化,使用 IonResource.fromAssetId .
Name Type Description
endpoint object The result of the Cesium ion asset endpoint service.
endpointResource Resource 原始资源用于检索端点.
See:

Extends

Members

readonly credits : Array.<Credit>

获得资产归属所需的信用.

readonly extension : string

资源的文件扩展名 .
Inherited From:

hasHeaders : boolean

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

headers : object

Additional HTTP headers that will be sent with the request.
Inherited From:

isBlobUri : boolean

True if the Resource refers to a blob URI.
Inherited From:

isCrossOriginUrl : boolean

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

isDataUri : boolean

True if the Resource refers to a data URI.
Inherited From:

proxy : Proxy

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

readonly queryParameters : object

Url 所附查询参数.
Inherited From:

request : Request

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

retryAttempts : number

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

retryCallback : function

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

readonly templateValues : object

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

url : string

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

Methods

static Cesium.IonResource.fromAssetId(assetId, options)Promise.<IonResource>

同步生成一个实例.
Name Type Description
assetId number The Cesium ion asset id.
options object optional 具有下列属性的天体:
Name Type Default Description
accessToken string Ion.defaultAccessToken optional The access token to use.
server string | Resource Ion.defaultServer optional The resource to the Cesium ion API server.
Returns:
A Promise to an instance representing the Cesium ion Asset.
Examples:
// Load a Cesium3DTileset with asset ID of 124624234
try {
  const resource = await Cesium.IonResource.fromAssetId(124624234);
  const tileset = await Cesium.Cesium3DTileset.fromUrl(resource);
  scene.primitives.add(tileset);
} catch (error) {
  console.error(`Error creating tileset: ${error}`);
}
//Load a CZML file with asset ID of 10890
Cesium.IonResource.fromAssetId(10890)
  .then(function (resource) {
    viewer.dataSources.add(Cesium.CzmlDataSource.load(resource));
  });

appendForwardSlash()

Appends a forward slash to the URL.
Inherited From:

appendQueryParameters(params)

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

clone(result)Resource

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

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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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
Inherited From:

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:
资源来源于当前版本.
Inherited From:

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.
Inherited From:
同步获得给定的资源头 。 返回一个承诺,决心 生成结果,或者如果资源未加载,则拒绝。 数据已装入 使用 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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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 是真的, 且请求没有足够优先级, 返回未定义 .
Inherited From:
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.
Inherited From:

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.
Inherited From:

toString()string

覆盖对象 # to String , 以使隐性字符串转换给出 complete URL represented by this Resource.
Returns:
The URL represented by this Resource
Inherited From:
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.