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 resource used to retrieve the endpoint. |
Extends
Members
readonly credits : Array.<Credit>
Gets the credits required for attribution of the asset.
The file extension of the resource.
- Inherited From:
True if the Resource has request headers. This is equivalent to checking if the headers property has any keys.
- Inherited From:
Additional HTTP headers that will be sent with the request.
- Inherited From:
True if the Resource refers to a blob URI.
- Inherited From:
True if the Resource refers to a cross origin URL.
- Inherited From:
True if the Resource refers to a data URI.
- Inherited From:
A proxy to be used when loading the resource.
- Inherited From:
Query parameters appended to the url.
- Inherited From:
request : Request
A Request object that will be used. Intended for internal use only.
- Inherited From:
The number of times the retryCallback should be called before giving up.
- Inherited From:
Function to call when a request for this resource fails. If it returns true or a Promise that resolves to true, the request will be retried.
- Inherited From:
The key/value pairs used to replace template parameters in the url.
- Inherited From:
The url to the resource with template values replaced, query string appended and encoded by proxy if one was set.
- 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 am 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));
});
Appends a forward slash to the URL.
- Inherited From:
Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
as opposed to adding them one at a time to the queryParameters property.
Name | Type | Description |
---|---|---|
params |
object | The query parameters |
- Inherited From:
clone(result) → Resource
Duplicates a Resource instance.
Name | Type | Description |
---|---|---|
result |
Resource | optional The object onto which to store the result. |
Returns:
The modified result parameter or a new Resource instance if one was not provided.
- Inherited From:
Asynchronously deletes 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.delete()
.then(function(body) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
Asynchronously loads 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. It's recommended that you use
the more specific functions eg. fetchJson, fetchBlob, etc.
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.fetch()
.then(function(body) {
// use the data
}).catch(function(error) {
// an error occurred
});
See:
Asynchronously loads the resource as raw binary data. Returns a promise that will resolve to
an ArrayBuffer 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.fetchArrayBuffer().then(function(arrayBuffer) {
// use the data
}).catch(function(error) {
// an error occurred
});
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:
Requests a resource using JSONP.
Name | Type | Default | Description |
---|---|---|---|
callbackParameterName |
string |
'callback'
|
optional The callback parameter name that the server expects. |
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 data asynchronously
resource.fetchJsonp().then(function(data) {
// use the loaded data
}).catch(function(error) {
// an error occurred
});
See:
Asynchronously loads the given resource as text. Returns a promise that will resolve to
a String 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 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:
Asynchronously loads the given resource as XML. Returns a promise that will resolve to
an XML Document 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 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:
Returns the base path of the Resource.
Name | Type | Default | Description |
---|---|---|---|
includeQuery |
boolean |
false
|
optional Whether or not to include the query string and fragment form the uri |
Returns:
The base URI of the resource
- Inherited From:
getDerivedResource(options) → Resource
Returns a resource relative to the current instance. All properties remain the same as the current instance unless overridden in options.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
An object with the following properties
|
Returns:
The resource derived from the current one.
- Inherited From:
Returns the url, optional with the query string and processed by a proxy.
Name | Type | Default | Description |
---|---|---|---|
query |
boolean |
false
|
optional If true, the query string is included. |
proxy |
boolean |
false
|
optional If true, the url is processed by the proxy object, if defined. |
Returns:
The url with all the requested components.
- Inherited From:
Asynchronously gets headers 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.head()
.then(function(headers) {
// use the data
}).catch(function(error) {
// an error occurred
});
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:
Asynchronously patches data to 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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | Data that is posted with the resource. | ||||||||||||
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.patch(data)
.then(function(result) {
// use the result
}).catch(function(error) {
// an error occurred
});
See:
Asynchronously posts data to 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 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | Data that is posted with the resource. | |||||||||||||||
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.post(data)
.then(function(result) {
// use the result
}).catch(function(error) {
// an error occurred
});
See:
Asynchronously puts data to 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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
object | Data that is posted with the resource. | ||||||||||||
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.put(data)
.then(function(result) {
// use the result
}).catch(function(error) {
// an error occurred
});
See:
Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
as opposed to adding them one at a time to the queryParameters property. If a value is already set, it will be replaced with the new value.
Name | Type | Default | Description |
---|---|---|---|
params |
object | The query parameters | |
useAsDefault |
boolean |
false
|
optional If true the params will be used as the default values, so they will only be set if they are undefined. |
- Inherited From:
Combines the specified object and the existing template values. This allows you to add many values at once,
as opposed to adding them one at a time to the templateValues property. If a value is already set, it will become an array and the new value will be appended.
Name | Type | Default | Description |
---|---|---|---|
template |
object | The template values | |
useAsDefault |
boolean |
false
|
optional If true the values will be used as the default values, so they will only be set if they are undefined. |
- Inherited From:
Override Object#toString so that implicit string conversion gives the
complete URL represented by this Resource.
Returns:
The URL represented by this Resource
- Inherited From: