封装 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 引用数据 URI,则为 True。
- Inherited From:
加载资源时使用的代理。
- Inherited From:
附加到 URL 的查询参数。
- Inherited From:
request : Request
将使用的 Request 对象。仅供内部使用。
- Inherited From:
在放弃之前应调用 retryCallback 的次数。
- Inherited From:
请求此资源失败时调用的函数。如果返回 true 或 Promise 解析为 true,则将重试请求。
- Inherited From:
用于替换 url 中的模板参数的键/值对。
- Inherited From:
替换了模板值的资源的 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
对象,具有以下属性:
|
Returns:
Promise,表示 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
复制Resource实例。
Name | Type | Description |
---|---|---|
result |
Resource | optional 要在其上存储结果的对象。 |
Returns:
修改后的结果参数或者新的 Resource 实例(如果未提供)。
- Inherited From:
异步删除给定的资源。 返回一个 Promise,该 Promise 将解析为
加载后的结果,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
对象,具有以下属性:
|
Returns:
一个 Promise,该 Promise 将在加载时解析为请求的数据。如果
request.throttle
为 true,并且请求的优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.delete()
.then(function(body) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步加载给定的资源。 返回一个 Promise,该 Promise 将解析为
加载后的结果,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。建议您使用
更具体的功能,例如。fetchJson、fetchBlob 等。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
对象,具有以下属性:
|
Returns:
一个 Promise,该 Promise 将在加载时解析为请求的数据。如果
request.throttle
为 true,并且请求的优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.fetch()
.then(function(body) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步加载资源作为原始二进制数据。 返回一个 Promise,该 Promise 将解析为
加载后为 ArrayBuffer,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Returns:
一个 Promise,该 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。 返回一个 Promise,该 Promise 将解析为
加载后为 Blob,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Returns:
一个 Promise,该 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:
异步加载给定的图像资源。 返回一个 Promise,该 Promise 将解析为
an ImageBitmap 如果
preferImageBitmap
为 true,并且浏览器支持 createImageBitmap
或其他
Image,如果图像加载失败,则为 reject。
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
具有以下属性的对象。
|
Returns:
一个 Promise,该 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 格式异步加载给定资源。 返回一个 Promise,该 Promise 将解析为
JSON 对象,如果资源加载失败,则拒绝。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。此功能
添加 'Accept: application/json,*/*;q=0.01' 添加到请求标头中,如果不是
已指定。
Returns:
一个 Promise,该 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,该 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:
异步加载给定的资源为文本。 返回一个 Promise,该 Promise 将解析为
一个 String,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Returns:
一个 Promise,该 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 形式异步加载给定的资源。 返回一个 Promise,该 Promise 将解析为
XML 文档,如果资源加载失败,则拒绝。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Returns:
一个 Promise,该 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 是否在 uri 中包含查询字符串和片段 |
Returns:
资源的基 URI
- Inherited From:
getDerivedResource(options) → Resource
返回相对于当前实例的资源。所有属性都与当前实例相同,除非在 options 中被覆盖。
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,该 Promise 将解析为
加载后的结果,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
对象,具有以下属性:
|
Returns:
一个 Promise,该 Promise 将在加载时解析为请求的数据。如果
request.throttle
为 true,并且请求的优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.head()
.then(function(headers) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步获取给定资源的 options。 返回一个 Promise,该 Promise 将解析为
加载后的结果,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
optional
对象,具有以下属性:
|
Returns:
一个 Promise,该 Promise 将在加载时解析为请求的数据。如果
request.throttle
为 true,并且请求的优先级不够高,则返回 undefined。
- Inherited From:
Example:
resource.options()
.then(function(headers) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
异步将数据修补到给定资源。 返回一个 Promise,该 Promise 将解析为
加载后的结果,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | 与资源一起发布的数据。 | ||||||||||||
options |
object |
optional
对象,具有以下属性:
|
Returns:
一个 Promise,该 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,该 Promise 将解析为
加载后的结果,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | 与资源一起发布的数据。 | |||||||||||||||
options |
object |
optional
对象,具有以下属性:
|
Returns:
一个 Promise,该 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,该 Promise 将解析为
加载后的结果,如果资源加载失败,则为 reject。 数据已加载
使用 XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨域资源共享 (CORS) 标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | 与资源一起发布的数据。 | ||||||||||||
options |
object |
optional
对象,具有以下属性:
|
Returns:
一个 Promise,该 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,以便隐式字符串转换给出
此资源表示的完整 URL。
Returns:
此资源表示的 URL
- Inherited From: