一个封装了 Cesium ion 资产访问的
Resource 实例。
该对象通常不直接实例化,请使用 IonResource.fromAssetId。
| Name | Type | Description |
|---|---|---|
endpoint |
object | Cesium ion 资产端点服务的结果。 |
endpointResource |
Resource | 用于获取端点的原始资源。 |
- Ion
- IonImageryProvider
- createWorldTerrain
- https://cesium.com
See:
Extends
Members
readonly credits : Array.<Credit>
获取资产署名所需的版权信息。
资源的文件扩展名。
- Inherited From:
如果 Resource 具有请求头则为 true。这等价于检查 headers 属性是否包含任何键。
- Inherited From:
将随请求一起发送的附加 HTTP 头。
- Inherited From:
如果 Resource 引用的是 blob URI 则为 true。
- Inherited From:
如果 Resource 引用的是跨源 URL 则为 true。
- Inherited From:
如果 Resource 引用的是 data URI 则为 true。
- Inherited From:
加载资源时要使用的代理。
- Inherited From:
附加到 url 的查询参数。
- Inherited From:
request : Request
将要使用的 Request 对象。仅供内部使用。
- Inherited From:
在放弃之前应当调用 retryCallback 的次数。
- Inherited From:
当此资源的请求失败时调用的函数。如果它返回 true 或解析为 true 的 Promise,则会重试该请求。
- Inherited From:
用于在 url 中替换模板参数的键/值对。
- Inherited From:
资源的 url,其中模板值已被替换、查询字符串已附加,并且在设置了代理时已由代理进行编码。
- Inherited From:
Methods
static Cesium.IonResource.fromAssetId(assetId, options) → Promise.<IonResource>
异步创建一个实例。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
assetId |
number | Cesium ion 资产 id。 | ||||||||||||
options |
object |
optional
包含以下属性的对象:
|
Returns:
一个解析为表示 Cesium ion 资产的实例的 Promise。
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));
});
向 URL 追加一个正斜杠。
- Inherited From:
将给定的对象与现有的查询参数合并。这允许你一次性添加多个参数,
而不是逐个添加到 queryParameters 属性中。
| Name | Type | Description |
|---|---|---|
params |
object | 查询参数 |
- Inherited From:
clone(result) → Resource
复制一个 Resource 实例。
| Name | Type | Description |
|---|---|---|
result |
Resource | optional 用于存放结果的那个对象。 |
Returns:
修改后的结果参数,如果未提供则为新的 Resource 实例。
- Inherited From:
异步删除给定的资源。返回一个在加载完成时解析为结果的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
包含以下属性的对象:
|
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.delete()
.then(function(body) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步加载给定的资源。返回一个在加载完成时解析为结果的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。建议改用更具体的函数,例如 fetchJson、fetchBlob 等。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
包含以下属性的对象:
|
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.fetch()
.then(function(body) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步将资源作为原始二进制数据加载。返回一个在加载完成时解析为 ArrayBuffer 的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
// load a single URL asynchronously
resource.fetchArrayBuffer().then(function(arrayBuffer) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步将给定的资源作为 blob 加载。返回一个在加载完成时解析为 Blob 的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
// load a single URL asynchronously
resource.fetchBlob().then(function(blob) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步加载给定的图像资源。返回一个在加载完成时解析为 ImageBitmap 的 promise(如果
preferImageBitmap 为 true 且浏览器支持 createImageBitmap),否则解析为 Image;如果图像加载失败则 reject。
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
包含以下属性的对象。
|
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- 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:
异步将给定的资源作为 JSON 加载。返回一个在加载完成时解析为 JSON 对象的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。如果尚未指定,此函数会向请求头添加 'Accept: application/json,*/*;q=0.01'。
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.fetchJson().then(function(jsonData) {
// Do something with the JSON object
}).catch(function(error) {
// an error occurred
});
See:
使用 JSONP 请求资源。
| Name | Type | Default | Description |
|---|---|---|---|
callbackParameterName |
string |
'callback'
|
optional 服务器所期望的回调参数名。 |
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
// load a data asynchronously
resource.fetchJsonp().then(function(data) {
// use the loaded data
}).catch(function(error) {
// an error occurred
});
See:
异步将给定的资源作为文本加载。返回一个在加载完成时解析为 String 的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- 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:
异步将给定的资源作为 XML 加载。返回一个在加载完成时解析为 XML Document 的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- 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:
返回 Resource 的基础路径。
| Name | Type | Default | Description |
|---|---|---|---|
includeQuery |
boolean |
false
|
optional 是否包含查询字符串和片段(fragment) |
Returns:
资源的基础 URI
- Inherited From:
getDerivedResource(options) → Resource
返回一个相对于当前实例的资源。除非在选项中被覆盖,否则所有属性都与当前实例保持相同。
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
包含以下属性的对象
|
Returns:
从当前资源派生出的资源。
- Inherited From:
返回 url,可选择包含查询字符串并由代理处理。
| Name | Type | Default | Description |
|---|---|---|---|
query |
boolean |
false
|
optional 如果为 true,则包含查询字符串。 |
proxy |
boolean |
false
|
optional 如果为 true,则 url 由代理对象处理(如果已定义)。 |
Returns:
包含所有所请求组成部分的 url。
- Inherited From:
异步获取给定资源的头信息。返回一个在加载完成时解析为结果的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
包含以下属性的对象:
|
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.head()
.then(function(headers) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步获取给定资源的选项。返回一个在加载完成时解析为结果的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
包含以下属性的对象:
|
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.options()
.then(function(headers) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步将补丁数据发送到给定的资源。返回一个在加载完成时解析为结果的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | 随资源一起提交的数据。 | ||||||||||||
options |
object |
optional
包含以下属性的对象:
|
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.patch(data)
.then(function(result) {
// use the result
}).catch(function(error) {
// an error occurred
});
See:
异步将数据发布到给定的资源。返回一个在加载完成时解析为结果的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | 随资源一起提交的数据。 | |||||||||||||||
options |
object |
optional
包含以下属性的对象:
|
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.post(data)
.then(function(result) {
// use the result
}).catch(function(error) {
// an error occurred
});
See:
异步将数据放入给定的资源。返回一个在加载完成时解析为结果的 promise,如果资源加载失败则 reject。数据通过 XMLHttpRequest 加载,这意味着为了向另一个源发起请求,服务器必须启用跨源资源共享(CORS)头。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | 随资源一起提交的数据。 | ||||||||||||
options |
object |
optional
包含以下属性的对象:
|
Returns:
一个在加载完成时解析为所请求数据的 promise。如果
request.throttle 为 true 且请求优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.put(data)
.then(function(result) {
// use the result
}).catch(function(error) {
// an error occurred
});
See:
将给定的对象与现有的查询参数合并。这允许你一次性添加多个参数,
而不是逐个添加到 queryParameters 属性中。如果某个值已经设置,它将被新值替换。
| Name | Type | Default | Description |
|---|---|---|---|
params |
object | 查询参数 | |
useAsDefault |
boolean |
false
|
optional 如果为 true,这些参数将用作默认值,因此只有当它们未定义时才会被设置。 |
- Inherited From:
将给定的对象与现有的模板值合并。这允许你一次性添加多个值,
而不是逐个添加到 templateValues 属性中。如果某个值已经设置,它将变成一个数组,新值会被追加到其中。
| Name | Type | Default | Description |
|---|---|---|---|
template |
object | 模板值 | |
useAsDefault |
boolean |
false
|
optional 如果为 true,这些值将用作默认值,因此只有当它们未定义时才会被设置。 |
- Inherited From:
重写 Object#toString,使得隐式字符串转换会给出
此 Resource 所表示的完整 URL。
Returns:
此 Resource 所表示的 URL
- Inherited From:
