There are some quite important differences to make an equivalent map version of the Zoomify sample. Let's see how:
sandbox directory./assets/data/1797-map-of-Dublin.jpg.imgCenter variable to [imgWidth / 2, imgHeight / 2];.var crossOrigin = 'anonymous';.ol.layer.Tile with ol.layer.Image.var source = new ol.source.ImageStatic({
attributions: [
new ol.Attribution({
html: '© <a href="https://commons.wikimedia.org/wiki/File:1797-map-of-Dublin.jpg#Summary">Wikipedia Commons</a>'
})
],
url: url,
imageSize: [imgWidth, imgHeight],
projection: proj,
imageExtent: proj.getExtent()
});You changed the center for the view by using a positive value for the second value in the imgCenter variable. It's because the ol.source.ImageStatic doesn't use the same origin as the ol.source.Zoomify.
We also set as an option, attributions referencing the credits to the Wikipedia Commons image.
The most important parts for configuration for the constructor are the url, imageSize, and imageExtent.
We also reused the projection based on pixels' units to set the projection for the source. As a reminder, you can inspect the available properties for the source.
The class helps to use any image as a layer using a pixel-based projection.
Its constructor is ol.source.ImageStatic. The constructor options are as follows:
To be complete, an ultimate source to review is the ol.source.ImageCanvas.
The ImageCanvas source is already an advanced topic, which is out of this book's scope; so, we will only explain its purpose.
If you remember, the default OpenLayers 3 behavior is to generate an HTML Canvas element to display the map image.
The purpose of ol.source.ImageCanvas is to help you inject in the HTML Canvas map element any arbitrary Canvas element. It's more flexible but the main drawback is the requirement to manage conversions between map units and the canvas element you want to add.
So, if you want to go further, you will need to learn Canvas drawing and also some projection calculations. At best, you will be able to integrate Canvas produced by other libraries. You also need to understand that a Canvas element can be built from vector elements and not only from raster images. It's a silly use case compared to the ideal separation between raster and vector layers.
Its constructor is ol.source.ImageCanvas. If you need it for a special purpose, the best way is to refer to the official documentation at http://openlayers.org/en/v3.0.0/apidoc/ol.source.ImageCanvas.html.
You can see it in action with D3 (another JavaScript library to generate graphic, charts, plots, and also maps), that can produce a canvas element you can use as a layer, as demonstrated in the official example at http://openlayers.org/en/v3.0.0/examples/d3.html.
For getting started with Canvas, use the Mozilla Developer part about the HTML 5 Canvas API at https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API.