A
Resource instance that encapsulates Cesium ion asset access.
This object is normally not instantiated directly, use IonResource.fromAssetId.
| Name | Type | Description |
|---|---|---|
endpoint |
object | The result of the Cesium ion asset endpoint service. |
endpointResource |
Resource | The original resource used to retrieve the endpoint. |
- Ion
- IonImageryProvider
- createWorldTerrain
- https://cesium.com
See:
Extends
Members
readonly credits : Array.<Credit>
Gets the credits required for attribution of the asset.
资源的文件扩展名。
- Inherited From:
如果Resource有请求标头则为true。这等同于检查headers属性是否有任何键。
- Inherited From:
将随请求发送的额外HTTP标头。
- Inherited From:
True if the Resource refers to a blob URI.
- Inherited From:
如果Resource引用跨域URL则为true。
- Inherited From:
True if the Resource refers to a data URI.
- Inherited From:
加载资源时要使用的代理。
- Inherited From:
追加到URL的查询参数。
- Inherited From:
request : Request
将使用的Request对象。仅供内部使用。
- Inherited From:
The number of times the retryCallback should be called before giving up.
- Inherited From:
此资源请求失败时调用的函数。如果返回true或解析为true的Promise,将重试请求。
- Inherited From:
用于替换URL中模板参数的键值对。
- Inherited From:
替换模板值后、追加查询字符串并由代理编码(如果设置了代理)的资源URL。
- Inherited From:
Methods
static Cesium.IonResource.fromAssetId(assetId, options) → Promise.<IonResource>
Asynchronously creates an instance.
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
assetId |
number | The Cesium ion asset id. | ||||||||||||
options |
object |
optional
An object with the following properties:
|
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));
});
向URL追加正斜杠。
- Inherited From:
合并指定对象和现有查询参数。这允许您一次添加多个参数,
而不是一次添加一个参数到queryParameters属性。
| Name | Type | Description |
|---|---|---|
params |
object | 查询参数 |
- Inherited From:
clone(result) → Resource
复制资源实例。
| Name | Type | Description |
|---|---|---|
result |
Resource | optional 存储结果的对象。 |
Returns:
修改后的结果参数,如果未提供则返回新的Resource实例。
- Inherited From:
异步删除给定资源。返回一个Promise,加载后将解析为
结果,如果资源加载失败则拒绝。数据使用XMLHttpRequest加载,
这意味着要向后端发出请求,服务器必须启用跨域资源共享(CORS)标头。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
具有下列属性的对象:
|
Returns:
加载后将解析为请求数据的Promise。如果
request.throttle为true且请求优先级不够高,则返回undefined。
- Inherited From:
Example:
resource.delete()
.then(function(body) {
// 使用数据
}).catch(function(error) {
// 发生错误
});
See:
异步加载给定资源。返回一个Promise,加载后将解析为
结果,如果资源加载失败则拒绝。数据使用XMLHttpRequest加载,
这意味着要向后端发出请求,服务器必须启用跨域资源共享(CORS)标头。建议您使用
更具体的函数,例如fetchJson、fetchBlob等。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
具有下列属性的对象:
|
Returns:
加载后将解析为请求数据的Promise。如果
request.throttle为true且请求优先级不够高,则返回undefined。
- Inherited From:
Example:
resource.fetch()
.then(function(body) {
// 使用数据
}).catch(function(error) {
// 发生错误
});
See:
异步加载资源为原始二进制数据。返回一个Promise,加载后将解析为
ArrayBuffer,如果资源加载失败则拒绝。数据使用XMLHttpRequest加载,
这意味着要向后端发出请求,服务器必须启用跨域资源共享(CORS)标头。
Returns:
加载后将解析为请求数据的Promise。如果
request.throttle为true且请求优先级不够高,则返回undefined。
- Inherited From:
Example:
// 异步加载单个URL
resource.fetchArrayBuffer().then(function(arrayBuffer) {
// 使用数据
}).catch(function(error) {
// 发生错误
});
See:
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:
a promise that will resolve to the requested data when loaded. Returns undefined if
request.throttle is true and the request does not have high enough priority.
- Inherited From:
Example:
// load a single URL asynchronously
resource.fetchBlob().then(function(blob) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
Asynchronously loads the given image resource. Returns a promise that will resolve to
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
An object with the following properties.
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if
request.throttle is true and the request does not have high enough priority.
- 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:
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,*/*;q=0.01' to the request headers, if not
already specified.
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if
request.throttle is true and the request does not have high enough priority.
- 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:
// 异步加载数据
resource.fetchJsonp().then(function(data) {
// 使用加载的数据
}).catch(function(error) {
// 发生错误
});
See:
异步加载给定资源为文本。返回一个Promise,加载后将解析为
字符串,如果资源加载失败则拒绝。数据使用XMLHttpRequest加载,
这意味着要向后端发出请求,服务器必须启用跨域资源共享(CORS)标头。
Returns:
加载后将解析为请求数据的Promise。如果
request.throttle为true且请求优先级不够高,则返回undefined。
- Inherited From:
Example:
// 从URL加载文本,设置自定义标头
const resource = new Resource({
url: 'http://someUrl.com/someJson.txt',
headers: {
'X-Custom-Header' : 'some value'
}
});
resource.fetchText().then(function(text) {
// 对文本执行某些操作
}).catch(function(error) {
// 发生错误
});
See:
异步加载给定资源为XML。返回一个Promise,加载后将解析为
XML文档,如果资源加载失败则拒绝。数据使用XMLHttpRequest加载,
这意味着要向后端发出请求,服务器必须启用跨域资源共享(CORS)标头。
Returns:
加载后将解析为请求数据的Promise。如果
request.throttle为true且请求优先级不够高,则返回undefined。
- Inherited From:
Example:
// 从URL加载XML,设置自定义标头
Cesium.loadXML('http://someUrl.com/someXML.xml', {
'X-Custom-Header' : 'some value'
}).then(function(document) {
// 对文档执行某些操作
}).catch(function(error) {
// 发生错误
});
See:
返回Resource的基础路径。
| Name | Type | Default | Description |
|---|---|---|---|
includeQuery |
boolean |
false
|
optional 是否包含URI中的查询字符串和片段 |
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,加载后将解析为
结果,如果资源加载失败则拒绝。数据使用XMLHttpRequest加载,
这意味着要向后端发出请求,服务器必须启用跨域资源共享(CORS)标头。
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
具有下列属性的对象:
|
Returns:
加载后将解析为请求数据的Promise。如果
request.throttle为true且请求优先级不够高,则返回undefined。
- Inherited From:
Example:
resource.head()
.then(function(headers) {
// 使用数据
}).catch(function(error) {
// 发生错误
});
See:
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:
|
Returns:
a promise that will resolve to the requested data when loaded. Returns undefined if
request.throttle is true and the request does not have high enough priority.
- Inherited From:
Example:
resource.options()
.then(function(headers) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步放置数据到给定资源。返回一个Promise,加载后将解析为
结果,如果资源加载失败则拒绝。数据使用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) {
// 使用结果
}).catch(function(error) {
// 发生错误
});
See:
异步向给定资源打补丁数据。返回一个Promise,加载后将解析为
结果,如果资源加载失败则拒绝。数据使用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) {
// 使用结果
}).catch(function(error) {
// 发生错误
});
See:
异步放置数据到给定资源。返回一个Promise,加载后将解析为
结果,如果资源加载失败则拒绝。数据使用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) {
// 使用结果
}).catch(function(error) {
// 发生错误
});
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:
