Skip to content

ImageOverlay

Used to load and display a single image over specific bounds of the map. Extends Layer.

Usage example

js
const imageUrl = 'https://maps.lib.utexas.edu/maps/historical/newark_nj_1922.jpg',
imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];
new ImageOverlay(imageUrl, imageBounds).addTo(map);

Options

OptionTypeDefaultDescription
opacityNumber1.0The opacity of the image overlay.
altString''Text for the alt attribute of the image (useful for accessibility).
interactiveBooleanfalseIf true, the image overlay will emit pointer events when clicked or hovered.
crossOrigin`BooleanString`false
errorOverlayUrlString''URL to the overlay image to show in place of the overlay that failed to load.
zIndexNumber1The explicit zIndex of the overlay layer.
classNameString''A custom class name to assign to the image. Empty by default.
decodingString'auto'Tells the browser whether to decode the image in a synchronous fashion,

Events

EventDataDescription
loadFired when the ImageOverlay layer has loaded its image
errorFired when the ImageOverlay layer fails to load its image