Appearance
KBE3D / KBCore / Cesium / IonResource
类: IonResource
A Resource instance that encapsulates Cesium ion asset access. This object is normally not instantiated directly, use IonResource.fromAssetId.
参数
The result of the Cesium ion asset endpoint service.
参数
The original resource used to retrieve the endpoint.
继承
属性
isBlobSupported
readonlystaticisBlobSupported:boolean
Returns true if blobs are supported.
继承自
DEFAULT
readonlystaticDEFAULT:Resource
A resource instance initialized to the current browser location
继承自
credits
readonlycredits:Credit[]
Gets the credits required for attribution of the asset.
headers
headers:
any
Additional HTTP headers that will be sent with the request.
继承自
request
request:
Request
A Request object that will be used. Intended for internal use only.
继承自
proxy
proxy:
Proxy
A proxy to be used when loading the resource.
继承自
retryCallback()
retryCallback: (...
params:any[]) =>any
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.
参数
params
...any[]
返回
any
继承自
retryAttempts
retryAttempts:
number
The number of times the retryCallback should be called before giving up.
继承自
queryParameters
readonlyqueryParameters:any
Query parameters appended to the url.
继承自
templateValues
readonlytemplateValues:any
The key/value pairs used to replace template parameters in the url.
继承自
url
url:
string
The url to the resource with template values replaced, query string appended and encoded by proxy if one was set.
继承自
extension
readonlyextension:string
The file extension of the resource.
继承自
isDataUri
isDataUri:
boolean
True if the Resource refers to a data URI.
继承自
isBlobUri
isBlobUri:
boolean
True if the Resource refers to a blob URI.
继承自
isCrossOriginUrl
isCrossOriginUrl:
boolean
True if the Resource refers to a cross origin URL.
继承自
hasHeaders
hasHeaders:
boolean
True if the Resource has request headers. This is equivalent to checking if the headers property has any keys.
继承自
方法
fromAssetId()
staticfromAssetId(assetId:number,options?: {accessToken?:string;server?:string|Resource; }):Promise<IonResource>
Asynchronously creates an instance.
参数
assetId
number
The Cesium ion asset id.
options?
An object with the following properties:
accessToken?
string
The access token to use.
server?
string | Resource
The resource to the Cesium ion API server.
返回
Promise<IonResource>
A Promise to an instance representing the Cesium ion Asset.
Examples
ts
// 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}`);
}ts
//Load a CZML file with asset ID of 10890
Cesium.IonResource.fromAssetId(10890)
.then(function (resource) {
viewer.dataSources.add(Cesium.CzmlDataSource.load(resource));
});fetchArrayBuffer()
staticfetchArrayBuffer(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request; }):Promise<ArrayBuffer> |undefined
Creates a Resource and calls fetchArrayBuffer() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
返回
Promise<ArrayBuffer> | undefined
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.
继承自
fetchBlob()
staticfetchBlob(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request; }):Promise<Blob> |undefined
Creates a Resource and calls fetchBlob() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
返回
Promise<Blob> | undefined
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.
继承自
fetchImage()
staticfetchImage(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;flipY?:boolean;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;preferBlob?:boolean;preferImageBitmap?:boolean;skipColorSpaceConversion?:boolean; }):Promise<HTMLImageElement|ImageBitmap> |undefined
Creates a Resource and calls fetchImage() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
flipY?
boolean
Whether to vertically flip the image during fetch and decode. Only applies when requesting an image and the browser supports <code>createImageBitmap</code>.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
preferBlob?
boolean
If true, we will load the image via a blob.
preferImageBitmap?
boolean
If true, image will be decoded during fetch and an <code>ImageBitmap</code> is returned.
skipColorSpaceConversion?
boolean
If true, any custom gamma or color profiles in the image will be ignored. Only applies when requesting an image and the browser supports <code>createImageBitmap</code>.
返回
Promise<HTMLImageElement | ImageBitmap> | undefined
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.
继承自
fetchText()
staticfetchText(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request; }):Promise<string> |undefined
Creates a Resource and calls fetchText() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
返回
Promise<string> | undefined
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.
继承自
fetchJson()
staticfetchJson(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request; }):Promise<any> |undefined
Creates a Resource and calls fetchJson() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
返回
Promise<any> | undefined
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.
继承自
fetchXML()
staticfetchXML(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request; }):Promise<XMLDocument> |undefined
Creates a Resource and calls fetchXML() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
返回
Promise<XMLDocument> | undefined
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.
继承自
fetchJsonp()
staticfetchJsonp(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;callbackParameterName?:string; }):Promise<any> |undefined
Creates a Resource from a URL and calls fetchJsonp() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
callbackParameterName?
string
The callback parameter name that the server expects.
返回
Promise<any> | undefined
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.
继承自
fetch()
staticfetch(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;responseType?:string;overrideMimeType?:string; }):Promise<any> |undefined
Creates a Resource from a URL and calls fetch() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
responseType?
string
The type of response. This controls the type of item returned.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
继承自
delete()
staticdelete(options: {url:string;data?:any;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;responseType?:string;overrideMimeType?:string; }):Promise<any> |undefined
Creates a Resource from a URL and calls delete() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
data?
any
Data that is posted with the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
responseType?
string
The type of response. This controls the type of item returned.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
继承自
head()
statichead(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;responseType?:string;overrideMimeType?:string; }):Promise<any> |undefined
Creates a Resource from a URL and calls head() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
responseType?
string
The type of response. This controls the type of item returned.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
继承自
options()
staticoptions(options: {url:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;responseType?:string;overrideMimeType?:string; }):Promise<any> |undefined
Creates a Resource from a URL and calls options() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
responseType?
string
The type of response. This controls the type of item returned.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
继承自
post()
staticpost(options: {url:string;data:any;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;responseType?:string;overrideMimeType?:string; }):Promise<any> |undefined
Creates a Resource from a URL and calls post() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
data
any
Data that is posted with the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
responseType?
string
The type of response. This controls the type of item returned.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
继承自
put()
staticput(options: {url:string;data:any;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;responseType?:string;overrideMimeType?:string; }):Promise<any> |undefined
Creates a Resource from a URL and calls put() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
data
any
Data that is posted with the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
responseType?
string
The type of response. This controls the type of item returned.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
继承自
patch()
staticpatch(options: {url:string;data:any;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;responseType?:string;overrideMimeType?:string; }):Promise<any> |undefined
Creates a Resource from a URL and calls patch() on it.
参数
options
A url or an object with the following properties
url
string
The url of the resource.
data
any
Data that is posted with the resource.
queryParameters?
any
An object containing query parameters that will be sent when retrieving the resource.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}).
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The Function to call when a request for this resource fails. If it returns true, the request will be retried.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
responseType?
string
The type of response. This controls the type of item returned.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
继承自
clone()
Duplicates a Resource instance.
参数
result?
The object onto which to store the result.
返回
The modified result parameter or a new Resource instance if one was not provided.
重写了
fetchImage()
fetchImage(
options?: {preferBlob?:boolean;preferImageBitmap?:boolean;flipY?:boolean;skipColorSpaceConversion?:boolean; }):Promise<HTMLImageElement|ImageBitmap> |undefined
Asynchronously loads the given image resource. Returns a promise that will resolve to an ImageBitmap if <code>preferImageBitmap</code> is true and the browser supports <code>createImageBitmap</code> or otherwise an Image once loaded, or reject if the image failed to load.
参数
options?
An object with the following properties.
preferBlob?
boolean
If true, we will load the image via a blob.
preferImageBitmap?
boolean
If true, image will be decoded during fetch and an <code>ImageBitmap</code> is returned.
flipY?
boolean
If true, image will be vertically flipped during decode. Only applies if the browser supports <code>createImageBitmap</code>.
skipColorSpaceConversion?
boolean
If true, any custom gamma or color profiles in the image will be ignored. Only applies if the browser supports <code>createImageBitmap</code>.
返回
Promise<HTMLImageElement | ImageBitmap> | undefined
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.
示例
ts
// 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
});重写了
toString()
toString():
string
Override Object#toString so that implicit string conversion gives the complete URL represented by this Resource.
返回
string
The URL represented by this Resource
继承自
getUrlComponent()
getUrlComponent(
query?:boolean,proxy?:boolean):string
Returns the url, optional with the query string and processed by a proxy.
参数
query?
boolean
If true, the query string is included.
proxy?
boolean
If true, the url is processed by the proxy object, if defined.
返回
string
The url with all the requested components.
继承自
setQueryParameters()
setQueryParameters(
params:any,useAsDefault?:boolean):void
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.
参数
params
any
The query parameters
useAsDefault?
boolean
If true the params will be used as the default values, so they will only be set if they are undefined.
返回
void
继承自
appendQueryParameters()
appendQueryParameters(
params:any):void
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.
参数
params
any
The query parameters
返回
void
继承自
Resource.appendQueryParameters
setTemplateValues()
setTemplateValues(
template:any,useAsDefault?:boolean):void
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.
参数
template
any
The template values
useAsDefault?
boolean
If true the values will be used as the default values, so they will only be set if they are undefined.
返回
void
继承自
getDerivedResource()
getDerivedResource(
options: {url?:string;queryParameters?:any;templateValues?:any;headers?:any;proxy?:Proxy;retryCallback?:RetryCallback;retryAttempts?:number;request?:Request;preserveQueryParameters?:boolean; }):Resource
Returns a resource relative to the current instance. All properties remain the same as the current instance unless overridden in options.
参数
options
An object with the following properties
url?
string
The url that will be resolved relative to the url of the current instance.
queryParameters?
any
An object containing query parameters that will be combined with those of the current instance.
templateValues?
any
Key/Value pairs that are used to replace template values (eg. {x}). These will be combined with those of the current instance.
headers?
any
Additional HTTP headers that will be sent.
proxy?
A proxy to be used when loading the resource.
retryCallback?
The function to call when loading the resource fails.
retryAttempts?
number
The number of times the retryCallback should be called before giving up.
request?
A Request object that will be used. Intended for internal use only.
preserveQueryParameters?
boolean
If true, this will keep all query parameters from the current resource and derived resource. If false, derived parameters will replace those of the current resource.
返回
The resource derived from the current one.
继承自
getBaseUri()
getBaseUri(
includeQuery?:boolean):string
Returns the base path of the Resource.
参数
includeQuery?
boolean
Whether or not to include the query string and fragment form the uri
返回
string
The base URI of the resource
继承自
appendForwardSlash()
appendForwardSlash():
void
Appends a forward slash to the URL.
返回
void
继承自
fetchArrayBuffer()
fetchArrayBuffer():
Promise<ArrayBuffer> |undefined
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.
返回
Promise<ArrayBuffer> | undefined
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.
示例
ts
// load a single URL asynchronously
resource.fetchArrayBuffer().then(function(arrayBuffer) {
// use the data
}).catch(function(error) {
// an error occurred
});继承自
fetchBlob()
fetchBlob():
Promise<Blob> |undefined
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.
返回
Promise<Blob> | undefined
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.
示例
ts
// load a single URL asynchronously
resource.fetchBlob().then(function(blob) {
// use the data
}).catch(function(error) {
// an error occurred
});继承自
fetchText()
fetchText():
Promise<string> |undefined
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.
返回
Promise<string> | undefined
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.
示例
ts
// 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
});继承自
fetchJson()
fetchJson():
Promise<any> |undefined
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.
返回
Promise<any> | undefined
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.
示例
ts
resource.fetchJson().then(function(jsonData) {
// Do something with the JSON object
}).catch(function(error) {
// an error occurred
});继承自
fetchXML()
fetchXML():
Promise<XMLDocument> |undefined
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.
返回
Promise<XMLDocument> | undefined
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.
示例
ts
// 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
});继承自
fetchJsonp()
fetchJsonp(
callbackParameterName?:string):Promise<any> |undefined
Requests a resource using JSONP.
参数
callbackParameterName?
string
The callback parameter name that the server expects.
返回
Promise<any> | undefined
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.
示例
ts
// load a data asynchronously
resource.fetchJsonp().then(function(data) {
// use the loaded data
}).catch(function(error) {
// an error occurred
});继承自
fetch()
fetch(
options?: {responseType?:string;headers?:any;overrideMimeType?:string; }):Promise<any> |undefined
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.
参数
options?
Object with the following properties:
responseType?
string
The type of response. This controls the type of item returned.
headers?
any
Additional HTTP headers to send with the request, if any.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
示例
ts
resource.fetch()
.then(function(body) {
// use the data
}).catch(function(error) {
// an error occurred
});继承自
delete()
delete(
options?: {responseType?:string;headers?:any;overrideMimeType?:string; }):Promise<any> |undefined
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.
参数
options?
Object with the following properties:
responseType?
string
The type of response. This controls the type of item returned.
headers?
any
Additional HTTP headers to send with the request, if any.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
示例
ts
resource.delete()
.then(function(body) {
// use the data
}).catch(function(error) {
// an error occurred
});继承自
head()
head(
options?: {responseType?:string;headers?:any;overrideMimeType?:string; }):Promise<any> |undefined
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.
参数
options?
Object with the following properties:
responseType?
string
The type of response. This controls the type of item returned.
headers?
any
Additional HTTP headers to send with the request, if any.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
示例
ts
resource.head()
.then(function(headers) {
// use the data
}).catch(function(error) {
// an error occurred
});继承自
options()
options(
options?: {responseType?:string;headers?:any;overrideMimeType?:string; }):Promise<any> |undefined
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.
参数
options?
Object with the following properties:
responseType?
string
The type of response. This controls the type of item returned.
headers?
any
Additional HTTP headers to send with the request, if any.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
示例
ts
resource.options()
.then(function(headers) {
// use the data
}).catch(function(error) {
// an error occurred
});继承自
post()
post(
data:any,options?: {data?:any;responseType?:string;headers?:any;overrideMimeType?:string; }):Promise<any> |undefined
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.
参数
data
any
Data that is posted with the resource.
options?
Object with the following properties:
data?
any
Data that is posted with the resource.
responseType?
string
The type of response. This controls the type of item returned.
headers?
any
Additional HTTP headers to send with the request, if any.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
示例
ts
resource.post(data)
.then(function(result) {
// use the result
}).catch(function(error) {
// an error occurred
});继承自
put()
put(
data:any,options?: {responseType?:string;headers?:any;overrideMimeType?:string; }):Promise<any> |undefined
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.
参数
data
any
Data that is posted with the resource.
options?
Object with the following properties:
responseType?
string
The type of response. This controls the type of item returned.
headers?
any
Additional HTTP headers to send with the request, if any.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
示例
ts
resource.put(data)
.then(function(result) {
// use the result
}).catch(function(error) {
// an error occurred
});继承自
patch()
patch(
data:any,options?: {responseType?:string;headers?:any;overrideMimeType?:string; }):Promise<any> |undefined
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.
参数
data
any
Data that is posted with the resource.
options?
Object with the following properties:
responseType?
string
The type of response. This controls the type of item returned.
headers?
any
Additional HTTP headers to send with the request, if any.
overrideMimeType?
string
Overrides the MIME type returned by the server.
返回
Promise<any> | undefined
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.
示例
ts
resource.patch(data)
.then(function(result) {
// use the result
}).catch(function(error) {
// an error occurred
});继承自
构造函数
构造函数
new IonResource(
endpoint:any,endpointResource:Resource):IonResource
参数
endpoint
any
endpointResource
返回
IonResource
