Functions
-
import {decode} from 'ol/Image';
Loads an image and decodes it to an
ImageBitmap
ifcreateImageBitmap()
is supported. Returns the loaded image otherwise.Name Type Description image
HTMLImageElement Image, not yet loaded.
src
string | undefined src
attribute of the image. Optional, not required if already present.Returns:
Promise resolving to anImageBitmap
or anHTMLImageElement
ifcreateImageBitmap()
is not supported.
-
import {load} from 'ol/Image';
Loads an image.
Name Type Description image
HTMLImageElement Image, not yet loaded.
src
string | undefined src
attribute of the image. Optional, not required if already present.Returns:
Promise resolving to anHTMLImageElement
.
Type Definitions
-
ImageObject{Object}
-
Properties:
Name Type Description extent
Extent | undefined Extent, if different from the requested one.
resolution
ResolutionLike | undefined Resolution, if different from the requested one. When x and y resolution are different, use the array type (
[xResolution, yResolution]
).pixelRatio
number | undefined Pixel ratio, if different from the requested one.
image
ImageLike Image.
-
Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments. The function returns a promise for an
image object
. -
A function that takes an
ImageWrapper
for the image and a{string}
for the src as arguments. It is supposed to make it so the underlying imagegetImage
is assigned the content specified by the src. If not specified, the default isfunction(image, src) { image.getImage().src = src; }
Providing a custom
imageLoadFunction
can be useful to load images with post requests or - in general - through XHR requests, where the src of the image element would be set to a data URI when the content is loaded. -
Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments. For images that cover any extent and resolution (static images), the loader function should not accept any arguments. The function returns an
image
, animage object
, or a promise for the same. For loaders that generate images, the promise should not resolve until the image is loaded. If the returned image does not match the extent, resolution or pixel ratio passed to the loader, it has to return animage object
with theimage
and the correctextent
,resolution
andpixelRatio
.