Contents

ImageSource

A union type that represents image sources that the framework can use for annotations and tile overlays.

Declaration

type ImageSource =
    | HTMLImageElement
    | HTMLCanvasElement
    | ImageBitmap
    | OffscreenCanvas;

Mentioned in

Discussion

An ImageSource is an HTMLImageElement, HTMLCanvasElement, ImageBitmap, or OffscreenCanvas. You can set an ImageSource directly on the ImageAnnotation image property or the MarkerAnnotation glyphImage property to display a preloaded or dynamically generated image. You can also wrap an ImageSource in a Promise to load the image asynchronously.

Utilizing Cross-origin Images

To enable cross-origin image sources for MapKit JS, instruct the browser to load them in CORS mode. The HTMLImageElement provides a crossOrigin property that you need to set to either "anonymous" (without cookies) or "use-credentials" (with a cookie) to opt-in to CORS request mode.

When compositing a HTMLCanvasElement or ImageBitmap, composite these objects from CORS-enabled cross-origin, or same-origin images.

See Also

Setting images