--- a/static/tiles2.js Mon Jul 07 21:32:38 2008 +0300
+++ b/static/tiles2.js Mon Jul 07 22:31:07 2008 +0300
@@ -1,4 +1,4 @@
-
+// A source of tile images of a specific width/height, zoom level range, and some other attributes
var Source = Class.create({
initialize: function (path, tile_width, tile_height, zoom_min, zoom_max) {
this.path = path;
@@ -10,11 +10,8 @@
this.refresh = false;
this.opt_key = this.opt_value = null;
},
-
- isValidZoomLevel: function (zoom_level) {
- return (zoom_level >= this.zoom_min && zoom_level <= this.zoom_max);
- },
-
+
+ // build a URL for the given tile image
build_url: function (col, row, zl, sw, sh) {
// two-bit hash (0-4) based on the (col, row)
var hash = ( (col % 2) << 1 | (row % 2) ) + 1;
@@ -23,7 +20,7 @@
var subdomain = "";
if (0)
- subdomain = "tile" + h + ".";
+ subdomain = "tile" + hash + ".";
// the (x, y) co-ordinates
var x = col * this.tile_width;
@@ -41,6 +38,7 @@
},
});
+// a viewport that contains a substrate which contains several zoom layers which contain many tiles
var Viewport = Class.create({
initialize: function (source, viewport_id) {
this.source = source;
@@ -256,7 +254,7 @@
this.zoom_layer = this.zoom_layers[delta];
// enable it
- this.zoom_layer.enable(10);
+ this.zoom_layer.enable(11);
// no need to .update_tiles or anything like that
@@ -274,6 +272,11 @@
this.zoom_timer = null;
}
+ // get other zoom layers out of the way
+ this.zoom_layers.each(function (zl) {
+ zl.disable();
+ });
+
// update the zoom layer
this.zoom_layer = zoom_new;
@@ -390,6 +393,7 @@
this.style.display = "block";
}
+// a zoom layer containing the tiles for one zoom level
var ZoomLayer = Class.create({
initialize: function (source, zoom_level) {
this.source = source;
@@ -400,20 +404,25 @@
this.tiles = [];
},
+ // add a tile to this zoom layer
add_tile: function (tile) {
this.div.appendChild(tile);
this.tiles.push(tile);
},
-
+
+ // make this zoom layer visible with the given z-index
enable: function (z_index) {
this.div.style.zIndex = z_index;
this.div.show();
},
-
+
+ // hide this zoom layer
disable: function (z_index) {
this.div.hide();
},
+ // update the tiles in this zoom layer so that they are in the correct position and of the correct size when
+ // viewed with the given zoom level
update_tiles: function (zoom_level) {
var zd = zoom_level - this.level;
@@ -439,7 +448,8 @@
});
-// scale the given co-ordinate by a zoom delta, if we zoom in (dz > 0), n will become larger, and if we zoom out (dz < 0), n will become smaller
+// scale the given co-ordinate by a zoom delta. If we zoom in (dz > 0), n will become larger, and if we zoom
+// out (dz < 0), n will become smaller.
function scaleByZoomDelta (n, dz) {
if (dz > 0)
return n << dz;