封装铯离子资产访问的
Resource
实例。
此对象通常不直接实例化,请使用IonResource.fromAssetId
。Name | Type | Description |
---|---|---|
endpoint |
Object | 铯离子资产端点服务的结果。 |
endpointResource |
Resource | 用于检索终结点的资源。 |
Extends
Members
readonly credits : Array.<Credit>
获取资产属性所需的学分。
资源的文件扩展名。
- Inherited From:
如果资源具有请求标头,则为True。这相当于检查headers属性是否有任何键。
- Inherited From:
将随请求一起发送的其他HTTP标头。
- Inherited From:
如果资源引用blob URI,则为True。
- Inherited From:
如果资源引用跨源URL,则为True。
- Inherited From:
如果资源引用数据URI,则为True。
- Inherited From:
proxy : Proxy
加载资源时要使用的代理。
- Inherited From:
附加到url的查询参数。
- Inherited From:
request : Request
将使用的请求对象。仅供内部使用。
- Inherited From:
放弃前应调用retryCallback的次数。
- Inherited From:
当此资源的请求失败时调用的函数。如果返回true或承诺解析为true,则将重试请求。
- Inherited From:
用于替换url中模板参数的键/值对。
- Inherited From:
替换模板值、附加查询字符串并由代理(如果已设置)编码的资源的url。
- Inherited From:
Methods
static Cesium.IonResource.fromAssetId(assetId, options) → Promise.<IonResource>
异步创建实例。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
assetId |
Number | 铯离子资产id。 | ||||||||||||
options |
Object | optional
具有以下属性的对象:
|
Returns:
对代表铯离子资产的am实例的承诺。
Examples:
//Load a Cesium3DTileset with asset ID of 124624234
viewer.scene.primitives.add(new Cesium.Cesium3DTileset({ url: Cesium.IonResource.fromAssetId(124624234) }));
//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:
修改后的结果参数或新的资源实例(如果未提供)。
- Inherited From:
异步删除给定资源。返回一个承诺
结果一旦加载,或拒绝如果资源加载失败。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
resource.delete()
.then(function(body) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
异步加载给定资源。返回一个承诺
结果一旦加载,或拒绝如果资源加载失败。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。建议您使用
更具体的函数,如fetchJson、fetchBlob等。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
resource.fetch()
.then(function(body) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
以原始二进制数据的形式异步加载资源。返回一个承诺
ArrayBuffer一旦加载,或在资源加载失败时拒绝。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
// load a single URL asynchronously
resource.fetchArrayBuffer().then(function(arrayBuffer) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
以blob的形式异步加载给定资源。返回一个承诺
一个Blob一旦加载,或者在资源加载失败时拒绝。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
// load a single URL asynchronously
resource.fetchBlob().then(function(blob) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象。
|
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
// load a single image asynchronously
resource.fetchImage().then(function(image) {
// use the loaded image
}).otherwise(function(error) {
// an error occurred
});
// load several images in parallel
when.all([resource1.fetchImage(), resource2.fetchImage()]).then(function(images) {
// images is an array containing all the loaded images
});
See:
以JSON的形式异步加载给定资源。返回一个承诺
JSON对象一旦加载,或者如果资源加载失败则拒绝。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。这个函数
如果没有,则将“Accept:application/json,*/*;q=0.01”添加到请求头中
已经指定。
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
resource.fetchJson().then(function(jsonData) {
// Do something with the JSON object
}).otherwise(function(error) {
// an error occurred
});
See:
使用JSONP请求资源。
Name | Type | Default | Description |
---|---|---|---|
callbackParameterName |
String |
'callback'
|
optional 服务器需要的回调参数名称。 |
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
// load a data asynchronously
resource.fetchJsonp().then(function(data) {
// use the loaded data
}).otherwise(function(error) {
// an error occurred
});
See:
以文本的形式异步加载给定资源。返回一个承诺
一个字符串一旦加载,或拒绝如果资源加载失败。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
// load text from a URL, setting a custom header
var 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
}).otherwise(function(error) {
// an error occurred
});
See:
以XML的形式异步加载给定资源。返回一个承诺
XML文档一旦加载,或在资源加载失败时拒绝。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- 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
}).otherwise(function(error) {
// an error occurred
});
See:
返回资源的基路径。
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:
异步获取给定资源的标头。返回一个承诺
结果一旦加载,或拒绝如果资源加载失败。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
resource.head()
.then(function(headers) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
异步获取给定资源的选项。返回一个承诺
结果一旦加载,或拒绝如果资源加载失败。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
resource.options()
.then(function(headers) {
// use the data
}).otherwise(function(error) {
// an error occurred
});
See:
异步提供给资源修补程序。返回一个承诺
结果一旦加载,或拒绝如果资源加载失败。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | 与资源一起过帐的数据。 | ||||||||||||
options |
Object | optional
具有以下属性的对象:
|
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
resource.patch(data)
.then(function(result) {
// use the result
}).otherwise(function(error) {
// an error occurred
});
See:
异步地将数据发布到给定的资源。返回一个承诺
结果一旦加载,或拒绝如果资源加载失败。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | 与资源一起过帐的数据。 | |||||||||||||||
options |
Object | optional
具有以下属性的对象:
|
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
resource.post(data)
.then(function(result) {
// use the result
}).otherwise(function(error) {
// an error occurred
});
See:
异步地将数据放入给定资源。返回一个承诺
结果一旦加载,或拒绝如果资源加载失败。数据已加载
使用XMLHttpRequest,这意味着为了向另一个源发出请求,
服务器必须启用跨源资源共享(CORS)标头。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | 与资源一起过帐的数据。 | ||||||||||||
options |
Object | optional
具有以下属性的对象:
|
Returns:
加载时将解析为请求的数据的承诺。如果
request.throttle
为真且请求的优先级不够高,则返回未定义。- Inherited From:
Example:
resource.put(data)
.then(function(result) {
// use the result
}).otherwise(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: