Commit 688ed2c7 authored by Sebastien Robin's avatar Sebastien Robin

stop using global variables everwhere to display the map

parent d824780b
...@@ -33,9 +33,7 @@ ...@@ -33,9 +33,7 @@
}, },
displayData: function(id){ displayData: function(id){
if (map !== undefined){ var zoomify_url, zoomify_width, zoomify_height;
map.destroy();
}
zoomify_url = "image/" + id + "/"; zoomify_url = "image/" + id + "/";
//XXX look at the xml definition inside image folder //XXX look at the xml definition inside image folder
if (id == 'openphotonet_imgp0034-1') { if (id == 'openphotonet_imgp0034-1') {
...@@ -46,7 +44,10 @@ ...@@ -46,7 +44,10 @@
zoomify_height = 1944; zoomify_height = 1944;
} }
$(this).form('render', 'image', {'image_id': id}); $(this).form('render', 'image', {'image_id': id});
$(loadOpenLayerZoomedImage); $(function() {
SafeImage.loadOpenLayerZoomedImage(zoomify_width,
zoomify_height, zoomify_url);
})
}, },
render: function(template, data){ render: function(template, data){
......
var zoomify_width = 29566; var SafeImage = (function() {
var zoomify_height = 14321;
var zoomify_url = "image/hs-2007-16-a-full_jpg/";
var map, zoomify; var that = {};
function loadOpenLayerZoomedImage(){ that.loadOpenLayerZoomedImage= function(zoomify_width,
/* First we initialize the zoomify pyramid (to get number of tiers) */ zoomify_height, zoomify_url){
var zoomify = new OpenLayers.Layer.Zoomify( "Zoomify", zoomify_url, if (that.map !== undefined){
new OpenLayers.Size( zoomify_width, zoomify_height ) ); that.map.destroy();
}
/* First we initialize the zoomify pyramid (to get number of tiers) */
that.zoomify = new OpenLayers.Layer.Zoomify( "Zoomify", zoomify_url,
new OpenLayers.Size( zoomify_width, zoomify_height ) );
/* Map with raster coordinates (pixels) from Zoomify image */ /* Map with raster coordinates (pixels) from Zoomify image */
var options = { var options = {
maxExtent: new OpenLayers.Bounds(0, 0, zoomify_width, zoomify_height), maxExtent: new OpenLayers.Bounds(0, 0, zoomify_width, zoomify_height),
maxResolution: Math.pow(2, zoomify.numberOfTiers-1 ), maxResolution: Math.pow(2, that.zoomify.numberOfTiers-1 ),
numZoomLevels: zoomify.numberOfTiers, numZoomLevels: that.zoomify.numberOfTiers,
units: 'pixels' units: 'pixels'
}; };
map = new OpenLayers.Map("map", options); that.map = new OpenLayers.Map("map", options);
map.addLayer(zoomify); that.map.addLayer(that.zoomify);
map.setBaseLayer(zoomify); that.map.setBaseLayer(that.zoomify);
map.zoomToMaxExtent(); that.map.zoomToMaxExtent();
}; };
\ No newline at end of file return that
}());
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment