Permalink
Browse files

More code to alleviate gah pain in #39

  • Loading branch information...
1 parent 18c96c3 commit 00cdb057149c43ddfb04c28c0d0bd671fd1bc10c @tmcw tmcw committed Mar 21, 2012
Showing with 25 additions and 5 deletions.
  1. +12 −2 modestmaps.js
  2. +1 −1 modestmaps.min.js
  3. +12 −2 src/layer.js
View
@@ -2129,11 +2129,21 @@ var MM = com.modestmaps = {
return this._redraw;
},
+ numTilesOnScreen: function() {
+ var tileCount = 0;
+ for (var name in this.levels) {
+ if (this.levels.hasOwnProperty(name)) {
+ var level = this.levels[name];
+ tileCount += this.tileElementsInLevel(level).length;
+ }
+ }
+ return tileCount;
+ },
+
// keeps cache below max size
// (called every time we receive a new tile and add it to the cache)
checkCache: function() {
- var numTilesOnScreen = this.parent.getElementsByTagName('img').length;
- var maxTiles = Math.max(numTilesOnScreen, this.maxTileCacheSize);
+ var maxTiles = Math.max(this.numTilesOnScreen(), this.maxTileCacheSize);
if (this.tileCacheSize > maxTiles) {
// sort from newest (highest) to oldest (lowest)
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -400,11 +400,21 @@
return this._redraw;
},
+ numTilesOnScreen: function() {
+ var tileCount = 0;
+ for (var name in this.levels) {
+ if (this.levels.hasOwnProperty(name)) {
+ var level = this.levels[name];
+ tileCount += this.tileElementsInLevel(level).length;
+ }
+ }
+ return tileCount;
+ },
+
// keeps cache below max size
// (called every time we receive a new tile and add it to the cache)
checkCache: function() {
- var numTilesOnScreen = this.parent.getElementsByTagName('img').length;
- var maxTiles = Math.max(numTilesOnScreen, this.maxTileCacheSize);
+ var maxTiles = Math.max(this.numTilesOnScreen(), this.maxTileCacheSize);
if (this.tileCacheSize > maxTiles) {
// sort from newest (highest) to oldest (lowest)

0 comments on commit 00cdb05

Please sign in to comment.