Static Image

Example of a static image layer.

This example uses a static image as a layer source. The map view is configured with a custom projection that translates image coordinates directly into map coordinates.

<!DOCTYPE html>
    <title>Static Image</title>
    <link rel="stylesheet" href="" type="text/css">
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src=",Element.prototype.classList,URL"></script>
    <script src=""></script>
    <div id="map" class="map"></div>
      // Map views always need a projection.  Here we just want to map image
      // coordinates directly to map coordinates, so we create a projection that uses
      // the image extent in pixels.
      var extent = [0, 0, 1024, 968];
      var projection = new ol.proj.Projection({
        code: 'xkcd-image',
        units: 'pixels',
        extent: extent

      var map = new ol.Map({
        layers: [
          new ol.layer.Image({
            source: new ol.source.ImageStatic({
              attributions: '© <a href="">xkcd</a>',
              url: '',
              projection: projection,
              imageExtent: extent
        target: 'map',
        view: new ol.View({
          projection: projection,
          center: ol.extent.getCenter(extent),
          zoom: 2,
          maxZoom: 8