loadImage(url, allowCrossOrigin) → Promise
Asynchronously loads the given image URL. Returns a promise that will resolve to
an
Image
once loaded, or reject if the image failed to load.
Name | Type | Default | Description |
---|---|---|---|
url |
String | Promise | The source of the image, or a promise for the URL. | |
allowCrossOrigin |
Boolean |
true
|
optional Whether to request the image using Cross-Origin Resource Sharing (CORS). CORS is only actually used if the image URL is actually cross-origin. Data URIs are never requested using CORS. |
Returns:
a promise that will resolve to the requested data when loaded.
Example:
// load a single image asynchronously
Cesium.loadImage('some/image/url.png').then(function(image) {
// use the loaded image
}).otherwise(function(error) {
// an error occurred
});
// load several images in parallel
when.all([loadImage('image1.png'), loadImage('image2.png')]).then(function(images) {
// images is an array containing all the loaded images
});
See:
Source:
Core/loadImage.js, line 46