Image Reprojection

Demonstrates client-side reprojection of single image source.

This example shows client-side reprojection of single image source.

<!DOCTYPE html>
<html>
  <head>
    <title>Image Reprojection</title>
    <link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src=""></script>
    <script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.4.4/proj4.js"></script>
  </head>
  <body>
    <div id="map" class="map"></div>
    <script>
      proj4.defs('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 ' +
          '+x_0=400000 +y_0=-100000 +ellps=airy ' +
          '+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 ' +
          '+units=m +no_defs');
      var imageExtent = [0, 0, 700000, 1300000];

      var map = new ol.Map({
        layers: [
          new ol.layer.Tile({
            source: new ol.source.OSM()
          }),
          new ol.layer.Image({
            source: new ol.source.ImageStatic({
              url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/' +
                     'British_National_Grid.svg/2000px-British_National_Grid.svg.png',
              crossOrigin: '',
              projection: 'EPSG:27700',
              imageExtent: imageExtent
            })
          })
        ],
        target: 'map',
        view: new ol.View({
          center: ol.proj.transform(
              ol.extent.getCenter(imageExtent), 'EPSG:27700', 'EPSG:3857'),
          zoom: 4
        })
      });
    </script>
  </body>
</html>