Merge pull request #6259 from ahocevar/simplify-zoomify-example

Simplify Zoomify example
This commit is contained in:
Andreas Hocevar
2016-12-16 09:47:43 +01:00
committed by GitHub

View File

@@ -1,29 +1,18 @@
goog.require('ol.Map'); goog.require('ol.Map');
goog.require('ol.View'); goog.require('ol.View');
goog.require('ol.layer.Tile'); goog.require('ol.layer.Tile');
goog.require('ol.proj.Projection');
goog.require('ol.source.Zoomify'); goog.require('ol.source.Zoomify');
var imgWidth = 9911; var imgWidth = 9911;
var imgHeight = 6100; 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({ var source = new ol.source.Zoomify({
url: 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?zoomify=' + url: 'http://vips.vtech.fr/cgi-bin/iipsrv.fcgi?zoomify=' +
'/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF/', '/mnt/MD1/AD00/plan_CHU-4HD-01/FOND.TIF/',
size: [imgWidth, imgHeight], size: [imgWidth, imgHeight],
crossOrigin: 'anonymous' crossOrigin: 'anonymous'
}); });
var extent = [0, -imgHeight, imgWidth, 0];
var map = new ol.Map({ var map = new ol.Map({
layers: [ layers: [
@@ -33,11 +22,10 @@ var map = new ol.Map({
], ],
target: 'map', target: 'map',
view: new ol.View({ view: new ol.View({
projection: proj, // adjust zoom levels to those provided by the source
center: imgCenter, resolutions: source.getTileGrid().getResolutions(),
zoom: 2, zoom: 2,
// constrain the center: center cannot be set outside // constrain the center: center cannot be set outside this extent
// this extent extent: extent
extent: [0, -imgHeight, imgWidth, 0]
}) })
}); });