Changeset 581
- Timestamp:
- 06/26/08 16:56:15 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/tom-tweenlite/lib/com/modestmaps/core/TileGrid.as
r580 r581 40 40 41 41 // pan, zoom and rotate 42 pr ivatevar _panX:Number = -TILE_WIDTH/2;43 pr ivatevar _panY:Number = -TILE_HEIGHT/2;44 pr ivatevar _scale:Number = 1;42 protected var _panX:Number = -TILE_WIDTH/2; 43 protected var _panY:Number = -TILE_HEIGHT/2; 44 protected var _scale:Number = 1; 45 45 46 46 protected var worldMatrix:Matrix; … … 110 110 public var zooming:Boolean; 111 111 112 protected static const DEFAULT_MAX_PARENT_SEARCH:int = 5; 113 protected static const DEFAULT_MAX_CHILD_SEARCH:int = 1; 114 protected static const DEFAULT_MAX_TILES_TO_KEEP:int = 256; 115 protected static const DEFAULT_TILE_BUFFER:int = 0; 116 protected static const DEFAULT_ENFORCE_BOUNDS:Boolean = false; 117 112 118 /** if we don't have a tile at currentZoom, onRender will look for tiles up to 5 levels out. 113 119 * set this to 0 if you only want the current zoom level's tiles 114 * WARNING: tiles will get scaled up A LOT for this, but maybe it beats blank tiles? 115 * TODO: move to MapConfig? */ 116 public static var MAX_PARENT_SEARCH:int = 5; 120 * WARNING: tiles will get scaled up A LOT for this, but maybe it beats blank tiles? */ 121 public var maxParentSearch:int = DEFAULT_MAX_PARENT_SEARCH; 117 122 /** if we don't have a tile at currentZoom, onRender will look for tiles up to one levels further in. 118 123 * set this to 0 if you only want the current zoom level's tiles 119 124 * WARNING: bad, bad nasty recursion possibilities really soon if you go much above 1 120 * - it works, but you probably don't want to change this number :) 121 * TODO: move to MapConfig? */ 122 public static var MAX_CHILD_SEARCH:int = 1; 125 * - it works, but you probably don't want to change this number :) */ 126 public var maxChildSearch:int = DEFAULT_MAX_CHILD_SEARCH; 123 127 124 128 // TODO: move to MapConfig 125 public static var MAX_TILES_TO_KEEP:int = 256; // 256*256*4bytes = 0.25MB ... so 256 tiles is 64MB of memory, minimum!129 public var maxTilesToKeep:int = DEFAULT_MAX_TILES_TO_KEEP; // 256*256*4bytes = 0.25MB ... so 256 tiles is 64MB of memory, minimum! 126 130 127 131 // 0 or 1, really: 2 will load *lots* of extra tiles 128 public static var TILE_BUFFER:int = 0;132 public var tileBuffer:int = DEFAULT_TILE_BUFFER; 129 133 130 134 // set this to true to enable enforcing of map bounds from the map provider's limits 131 public static var ENFORCE_BOUNDS:Boolean = false;135 public var enforceBoundsEnabled:Boolean = DEFAULT_ENFORCE_BOUNDS; 132 136 133 137 public var mapWidth:Number; … … 294 298 // optionally pad it out a little bit more 295 299 // TODO: investigate giving a directional bias to TILE_BUFFER when panning quickly 296 minCol -= TILE_BUFFER;297 maxCol += TILE_BUFFER;298 minRow -= TILE_BUFFER;299 maxRow += TILE_BUFFER;300 minCol -= tileBuffer; 301 maxCol += tileBuffer; 302 minRow -= tileBuffer; 303 maxRow += tileBuffer; 300 304 301 305 visibleTiles = []; … … 353 357 354 358 // if it still doesn't have enough images yet, or it's fading in, try a double size parent instead 355 if ( MAX_PARENT_SEARCH> 0 && !tileReady && currentZoom > minZoom) {359 if (maxParentSearch > 0 && !tileReady && currentZoom > minZoom) { 356 360 pkey = parentKey(col, row, currentZoom, currentZoom-1); 357 361 if (alreadySeen[pkey] is Tile) { … … 369 373 370 374 // if it doesn't have an image yet, see if we can make it from smaller images 371 if (!foundParent && MAX_CHILD_SEARCH> 0 && !tileReady && currentZoom < maxZoom) {372 for (var czoom:int = currentZoom+1; czoom <= Math.min(maxZoom, currentZoom+ MAX_CHILD_SEARCH); czoom++) {375 if (!foundParent && maxChildSearch > 0 && !tileReady && currentZoom < maxZoom) { 376 for (var czoom:int = currentZoom+1; czoom <= Math.min(maxZoom, currentZoom+maxChildSearch); czoom++) { 373 377 var ckeys:Array = childKeys(col, row, currentZoom, czoom); 374 378 for each (var ckey:String in ckeys) { … … 393 397 } 394 398 395 var endZoomSearch:int = Math.max(minZoom, currentZoom- MAX_PARENT_SEARCH);399 var endZoomSearch:int = Math.max(minZoom, currentZoom-maxParentSearch); 396 400 397 401 var stillNeedsAnImage:Boolean = !foundParent && foundChildren < 4; 398 402 // if it still doesn't have an image yet, try more parent zooms 399 if (stillNeedsAnImage && MAX_PARENT_SEARCH> 1 && tileReady && currentZoom > minZoom) {403 if (stillNeedsAnImage && maxParentSearch > 1 && tileReady && currentZoom > minZoom) { 400 404 for (pzoom = startZoomSearch; pzoom >= endZoomSearch; pzoom--) { 401 405 pkey = parentKey(col, row, currentZoom, pzoom); … … 464 468 // all the visible tiles will be at the end of recentlySeen 465 469 // let's make sure we keep them around: 466 var maxRecentlySeen:int = Math.max(visibleTiles.length, MAX_TILES_TO_KEEP);470 var maxRecentlySeen:int = Math.max(visibleTiles.length,maxTilesToKeep); 467 471 /* trace(); 468 472 trace('visibleTiles', visibleTiles.length); … … 473 477 if (recentlySeen.length > maxRecentlySeen) { 474 478 // throw away keys at the beginning of recentlySeen 475 recentlySeen = recentlySeen.slice(recentlySeen.length - MAX_TILES_TO_KEEP, recentlySeen.length);479 recentlySeen = recentlySeen.slice(recentlySeen.length - maxTilesToKeep, recentlySeen.length); 476 480 // loop over our internal tile cache 477 481 // and throw out tiles not in recentlySeen … … 1020 1024 protected function enforceBounds():Boolean 1021 1025 { 1022 if (! ENFORCE_BOUNDS) {1026 if (!enforceBoundsEnabled) { 1023 1027 return false; 1024 1028 }
