--- layout: tutorial_v2 title: Overlays --- ## Overlays There are 3 overlays in the Leaflet API: - [`ImageOverlay`](/reference.html#imageoverlay): Raster Layer, Extends [`Layer`](/reference.html#layer) - [`VideoOverlay`](/reference.html#videooverlay): Raster Layer, Extends [`ImageOverlay`](/reference.html#imageoverlay) - [`SVGOverlay`](/reference.html#svgoverlay): Vector Layer, Extends [`ImageOverlay`](/reference.html#imageoverlay) In this tutorial, you’ll learn how to use these overlays. ### `ImageOverlay` `L.ImageOverlay` is used to load and display a single image over specific bounds of the map. To add an image overlay [`L.ImageOverlay`](/reference.html#imageoverlay) use this: ``` var imageOverlay = L.imageOverlay(imageUrl, latLngBounds, options); ``` #### Creating a map First of all, create a Leaflet map and add a background `L.TileLayer` in the usual way: ``` var map = L.map('map').setView([37.8, -96], 4); var osm = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© OpenStreetMap' }).addTo(map); ``` Let's create an image overlay with multiple options: ``` var imageUrl = 'https://maps.lib.utexas.edu/maps/historical/newark_nj_1922.jpg'; var errorOverlayUrl = 'https://cdn-icons-png.flaticon.com/512/110/110686.png'; var altText = 'Image of Newark, N.J. in 1922. Source: The University of Texas at Austin, UT Libraries Map Collection.'; var latLngBounds = L.latLngBounds([[40.799311, -74.118464], [40.68202047785919, -74.33]]); var imageOverlay = L.imageOverlay(imageUrl, latLngBounds, { opacity: 0.8, errorOverlayUrl: errorOverlayUrl, alt: altText, interactive: true }).addTo(map); ``` If you want to see the area which is covered by the ImageOverlay, you can add a [`L.Rectangle`](/reference.html#rectangle) with the same `L.LatLngBounds` to the map: ``` L.rectangle(latLngBounds).addTo(map); map.fitBounds(latLngBounds); ``` - `opacity` defines the opacity of the image overlay, it equals to `1.0` by default. Decrease this value to make an image overlay transparent and to expose the underlying map layer. - `errorOverlayUrl` is a URL to the overlay image to show in place of the overlay that failed to load. - `alt` sets the HTML [`alt`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-alt) attribute to provide an alternative text description of the image. Alternative text is essential information for screen reader users. It can also benefit people during poor network connectivity, in the case the image fails to load. Moreover, it can improve the SEO of a website. - `interactive` is `false` by default. If `true`, the image overlay will emit mouse events when clicked or hovered. You can find other options of `L.ImageOverlay` in the [documentation](/reference.html#imageoverlay). {% include frame.html url="example-image.html" %} ### `VideoOverlay` Video used to be a hard task when building a webpage, until the [`