IonResource

new Cesium.IonResource(endpoint, endpointResource)

封装铯离子资产访问的Resource实例。 此对象通常不直接实例化,请使用IonResource.fromAssetId
Name Type Description
endpoint Object 铯离子资产端点服务的结果。
endpointResource Resource 用于检索终结点的资源。
See:

Extends

Members

readonly credits : Array.<Credit>

获取资产属性所需的学分。

readonly extension : String

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

hasHeaders : Boolean

如果资源具有请求标头,则为True。这相当于检查headers属性是否有任何键。
Inherited From:

headers : Object

将随请求一起发送的其他HTTP标头。
Inherited From:

isBlobUri : Boolean

如果资源引用blob URI,则为True。
Inherited From:

isCrossOriginUrl : Boolean

如果资源引用跨源URL,则为True。
Inherited From:

isDataUri : Boolean

如果资源引用数据URI,则为True。
Inherited From:
加载资源时要使用的代理。
Inherited From:

readonly queryParameters : Object

附加到url的查询参数。
Inherited From:
将使用的请求对象。仅供内部使用。
Inherited From:

retryAttempts : Number

放弃前应调用retryCallback的次数。
Inherited From:

retryCallback : function

当此资源的请求失败时调用的函数。如果返回true或承诺解析为true,则将重试请求。
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 铯离子资产id。
options Object optional 具有以下属性的对象:
Name Type Default Description
accessToken String Ion.defaultAccessToken optional 要使用的访问令牌。
server String | Resource Ion.defaultServer optional 铯离子API服务器的资源。
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));
  });

appendForwardSlash()

向URL追加正斜杠。
Inherited From:

appendQueryParameters(params)

组合指定对象和现有查询参数。这允许您一次添加多个参数, 而不是一次一个地将它们添加到queryParameters属性中。
Name Type Description
params Object 查询参数
Inherited From:

clone(result)Resource

复制资源实例。
Name Type Description
result Resource optional 要将结果存储到的对象。
Returns:
修改后的结果参数或新的资源实例(如果未提供)。
Inherited From:

delete(options)Promise.<*>|undefined

异步删除给定资源。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Inherited From:
Example:
resource.delete()
  .then(function(body) {
      // use the data
  }).otherwise(function(error) {
      // an error occurred
  });
See:

fetch(options)Promise.<*>|undefined

异步加载给定资源。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。建议您使用 更具体的函数,如fetchJson、fetchBlob等。
Name Type Description
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Inherited From:
Example:
resource.fetch()
  .then(function(body) {
      // use the data
  }).otherwise(function(error) {
      // an error occurred
  });
See:

fetchArrayBuffer()Promise.<ArrayBuffer>|undefined

以原始二进制数据的形式异步加载资源。返回一个承诺 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:

fetchBlob()Promise.<Blob>|undefined

以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:

fetchImage(options)Promise.<ImageBitmap>|Promise.<HTMLImageElement>|undefined

异步加载给定的图像资源。返回一个承诺 如果ImageBitmap为真且浏览器支持createImageBitmap或其他 Image一旦加载,或拒绝如果图像加载失败。
Name Type Description
options Object optional 具有以下属性的对象。
Name Type Default Description
preferBlob Boolean false optional 如果为true,我们将通过blob加载图像。
preferImageBitmap Boolean false optional 如果为true,则在获取期间对图像进行解码,并返回ImageBitmap
flipY Boolean false optional 如果为真,则在解码期间图像将垂直翻转。仅适用于浏览器支持createImageBitmap的情况。
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:

fetchJson()Promise.<*>|undefined

以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:

fetchJsonp(callbackParameterName)Promise.<*>|undefined

使用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:

fetchText()Promise.<String>|undefined

以文本的形式异步加载给定资源。返回一个承诺 一个字符串一旦加载,或拒绝如果资源加载失败。数据已加载 使用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:

fetchXML()Promise.<XMLDocument>|undefined

以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:

getBaseUri(includeQuery)String

返回资源的基路径。
Name Type Default Description
includeQuery Boolean false optional 是否包含构成uri的查询字符串和片段
Returns:
资源的基URI
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 将发送的其他HTTP头。
proxy Proxy optional 加载资源时要使用的代理。
retryCallback Resource.RetryCallback optional 加载资源时要调用的函数失败。
retryAttempts Number optional 放弃前应调用retryCallback的次数。
request Request optional 将使用的请求对象。仅供内部使用。
preserveQueryParameters Boolean false optional 如果为true,则将保留当前资源和派生资源的所有查询参数。如果为false,则派生参数将替换当前资源的参数。
Returns:
从当前资源派生的资源。
Inherited From:

getUrlComponent(query, proxy)String

返回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 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Inherited From:
Example:
resource.head()
  .then(function(headers) {
      // use the data
  }).otherwise(function(error) {
      // an error occurred
  });
See:

options(options)Promise.<*>|undefined

异步获取给定资源的选项。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Inherited From:
Example:
resource.options()
  .then(function(headers) {
      // use the data
  }).otherwise(function(error) {
      // an error occurred
  });
See:

patch(data, options)Promise.<*>|undefined

异步提供给资源修补程序。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
data Object 与资源一起过帐的数据。
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Inherited From:
Example:
resource.patch(data)
  .then(function(result) {
      // use the result
  }).otherwise(function(error) {
      // an error occurred
  });
See:

post(data, options)Promise.<*>|undefined

异步地将数据发布到给定的资源。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
data Object 与资源一起过帐的数据。
options Object optional 具有以下属性的对象:
Name Type Description
data Object optional 与资源一起过帐的数据。
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Inherited From:
Example:
resource.post(data)
  .then(function(result) {
      // use the result
  }).otherwise(function(error) {
      // an error occurred
  });
See:

put(data, options)Promise.<*>|undefined

异步地将数据放入给定资源。返回一个承诺 结果一旦加载,或拒绝如果资源加载失败。数据已加载 使用XMLHttpRequest,这意味着为了向另一个源发出请求, 服务器必须启用跨源资源共享(CORS)标头。
Name Type Description
data Object 与资源一起过帐的数据。
options Object optional 具有以下属性的对象:
Name Type Description
responseType String optional 响应的类型。这控制返回的项的类型。
headers Object optional 要与请求一起发送的附加HTTP标头(如果有)。
overrideMimeType String optional 重写服务器返回的MIME类型。
Returns:
加载时将解析为请求的数据的承诺。如果request.throttle为真且请求的优先级不够高,则返回未定义。
Inherited From:
Example:
resource.put(data)
  .then(function(result) {
      // use the result
  }).otherwise(function(error) {
      // an error occurred
  });
See:

setQueryParameters(params, useAsDefault)

组合指定对象和现有查询参数。这允许您一次添加多个参数, 而不是一次一个地将它们添加到queryParameters属性中。如果已经设置了值,则将用新值替换该值。
Name Type Default Description
params Object 查询参数
useAsDefault Boolean false optional 如果为true,则参数将用作默认值,因此只有在未定义时才会设置这些值。
Inherited From:

setTemplateValues(template, useAsDefault)

组合指定对象和现有模板值。这样可以同时添加多个值, 而不是一次一个地将它们添加到templateValues属性中。如果已经设置了一个值,它将成为一个数组,新值将被追加。
Name Type Default Description
template Object 模板值
useAsDefault Boolean false optional 如果为true,则值将用作默认值,因此只有在未定义时才会设置这些值。
Inherited From:

toString()String

重写Object#toString,以便隐式字符串转换为 此资源表示的完整URL。
Returns:
此资源表示的URL
Inherited From: