Zoomify

Example of a Zoomify source.

Zoomify is a format for deep-zooming into high resolution images. This example shows how to use the Zoomify source with a pixel projection.

<!DOCTYPE html>
<html>
  <head>
    <title>Zoomify</title>
    <link rel="stylesheet" href="https://openlayers.org/en/v3.20.0/css/ol.css" type="text/css">
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
    <script src="https://openlayers.org/en/v3.20.0/build/ol.js"></script>
  </head>
  <body>
    <div id="map" class="map"></div>
    <script>
      var imgWidth = 9911;
      var imgHeight = 6100;

      var imgCenter = [imgWidth / 2, -imgHeight / 2];

      // Maps always need a projection, but Zoomify layers are not geo-referenced, and
      // are only measured in pixels.  So, we create a fake projection that the map
      // can use to properly display the layer.
      var proj = new ol.proj.Projection({
        code: 'ZOOMIFY',
        units: 'pixels',
        extent: [0, 0, imgWidth, imgHeight]
      });

      var source = new ol.source.Zoomify({
        url: 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?zoomify=' +
            '/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF/',
        size: [imgWidth, imgHeight],
        crossOrigin: 'anonymous'
      });

      var map = new ol.Map({
        layers: [
          new ol.layer.Tile({
            source: source
          })
        ],
        target: 'map',
        view: new ol.View({
          projection: proj,
          center: imgCenter,
          zoom: 2,
          // constrain the center: center cannot be set outside
          // this extent
          extent: [0, -imgHeight, imgWidth, 0]
        })
      });
    </script>
  </body>
</html>