I am using OpenLayers 3 to display a single image. I am trying to write a function that will zoom so the left side of the image touches to the left side of the container and the right side of the image touches the right side of the container. It doesn't matter if the top and bottom of the image is outside the view.
I have set the projection extent to be the same as the image resolution:
var extent = [0, 0, 2480, 3508];
projection = new ol.proj.Projection({
code: 'image',
units: 'pixels',
extent: extent
});
I was experimenting with the fitExtent
function in the console window using the code:
map.getView().fitExtent([0,0,2480,3508],map.getSize())
The result I got wasn't quite what I was expecting. The image is centred, but appears much smaller than I was expecting. I was expecting at least the top and bottom of the image to be touching the top and bottom of the container.
An explanation of why this is happening would be fantastic. A solution that fits the image so the left is on the left and the right is on the right (a zoomToExtentY function) would be even better.