Permalink
Browse files

improve redraw behaviour in getTileComplete

  • Loading branch information...
RandomEtc committed Apr 12, 2011
1 parent c202b0a commit 4e7c6b6ad0cae2893302fd33c471503a0c3f1be9
Showing with 50 additions and 28 deletions.
  1. +4 −0 CHANGELOG
  2. +22 −13 modestmaps.js
  3. +2 −2 modestmaps.min.js
  4. +9 −11 src/map.js
  5. +12 −1 src/requests.js
  6. +1 −1 src/start.js
View
@@ -8,6 +8,10 @@ Following the semantic versioning recommendation best we can:
minor version, and backwards incompatible API changes increment
the major version." -- http://semver.org/
+v0.14.3
+ - improve redraw behavior by ensuring layer is visible in getTileComplete
+ - use a closure in v0.14.2's setTimeout to ensure proper 'this'
+
v0.14.2
- add setTimeout to processQueue to avoid stack overflow/recursion
bug in IE 7/8 (https://github.com/stamen/modestmaps-js/issues/12)
View
@@ -1,5 +1,5 @@
/*!
- * Modest Maps JS v0.14.2
+ * Modest Maps JS v0.14.3
* http://modestmaps.com/
*
* Copyright (c) 2010 Stamen Design, All Rights Reserved.
@@ -816,6 +816,17 @@ if (!com) {
}
}
},
+
+ getProcessQueue: function() {
+ // let's only create this closure once...
+ if (!this._processQueue) {
+ var theManager = this;
+ this._processQueue = function() {
+ theManager.processQueue();
+ }
+ }
+ return this._processQueue;
+ },
processQueue: function(sortFunc) {
if (sortFunc && this.requestQueue.length > 8) {
@@ -897,7 +908,7 @@ if (!com) {
// use setTimeout() to avoid the IE recursion limit, see
// http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/
// and https://github.com/stamen/modestmaps-js/issues/12
- setTimeout(theManager.processQueue, 0);
+ setTimeout(theManager.getProcessQueue(), 0);
};
}
@@ -1559,17 +1570,6 @@ if (!com) {
theMap.recentTilesById[tile.id] = record;
theMap.recentTiles.push(record);
- // add tile to its layer:
- var theLayer = theMap.layers[tile.coord.zoom];
- theLayer.appendChild(tile);
-
- //if (!theMap.lastTileReceived) {
- // theMap.lastTileReceived = new Date().getTime();
- //}
- //var t = new Date().getTime();
- //console.log(tile.coord.toString() + ' ' + (t-theMap.lastTileReceived));
- //theMap.lastTileReceived = t;
-
// position this tile (avoids a full draw() call):
var theCoord = theMap.coordinate.zoomTo(tile.coord.zoom);
var scale = Math.pow(2, theMap.coordinate.zoom - tile.coord.zoom);
@@ -1582,6 +1582,15 @@ if (!com) {
tile.style.width = Math.ceil(theMap.provider.tileWidth * scale) + 'px';
tile.style.height = Math.ceil(theMap.provider.tileHeight * scale) + 'px';
+ // add tile to its layer
+ var theLayer = theMap.layers[tile.coord.zoom];
+ theLayer.appendChild(tile);
+
+ // ensure the layer is visible if it's still the current layer
+ if (Math.round(theMap.coordinate.zoom) == tile.coord.zoom) {
+ theLayer.style.display = 'block';
+ }
+
// request a lazy redraw of all layers
// this will remove tiles that were only visible
// to cover this tile while it loaded:
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -652,17 +652,6 @@
theMap.recentTilesById[tile.id] = record;
theMap.recentTiles.push(record);
- // add tile to its layer:
- var theLayer = theMap.layers[tile.coord.zoom];
- theLayer.appendChild(tile);
-
- //if (!theMap.lastTileReceived) {
- // theMap.lastTileReceived = new Date().getTime();
- //}
- //var t = new Date().getTime();
- //console.log(tile.coord.toString() + ' ' + (t-theMap.lastTileReceived));
- //theMap.lastTileReceived = t;
-
// position this tile (avoids a full draw() call):
var theCoord = theMap.coordinate.zoomTo(tile.coord.zoom);
var scale = Math.pow(2, theMap.coordinate.zoom - tile.coord.zoom);
@@ -675,6 +664,15 @@
tile.style.width = Math.ceil(theMap.provider.tileWidth * scale) + 'px';
tile.style.height = Math.ceil(theMap.provider.tileHeight * scale) + 'px';
+ // add tile to its layer
+ var theLayer = theMap.layers[tile.coord.zoom];
+ theLayer.appendChild(tile);
+
+ // ensure the layer is visible if it's still the current layer
+ if (Math.round(theMap.coordinate.zoom) == tile.coord.zoom) {
+ theLayer.style.display = 'block';
+ }
+
// request a lazy redraw of all layers
// this will remove tiles that were only visible
// to cover this tile while it loaded:
View
@@ -112,6 +112,17 @@
}
}
},
+
+ getProcessQueue: function() {
+ // let's only create this closure once...
+ if (!this._processQueue) {
+ var theManager = this;
+ this._processQueue = function() {
+ theManager.processQueue();
+ }
+ }
+ return this._processQueue;
+ },
processQueue: function(sortFunc) {
if (sortFunc && this.requestQueue.length > 8) {
@@ -193,7 +204,7 @@
// use setTimeout() to avoid the IE recursion limit, see
// http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/
// and https://github.com/stamen/modestmaps-js/issues/12
- setTimeout(theManager.processQueue, 0);
+ setTimeout(theManager.getProcessQueue(), 0);
};
}
View
@@ -1,5 +1,5 @@
/*!
- * Modest Maps JS v0.14.2
+ * Modest Maps JS v0.14.3
* http://modestmaps.com/
*
* Copyright (c) 2010 Stamen Design, All Rights Reserved.

0 comments on commit 4e7c6b6

Please sign in to comment.