OpenLayers.TileManager

Provides queueing of image requests and caching of image elements.

Queueing avoids unnecessary image requests while changing zoom levels quickly, and helps improve dragging performance on mobile devices that show a lag in dragging when loading of new images starts.  zoomDelay and moveDelay are the configuration options to control this behavior.

Caching avoids setting the src on image elements for images that have already been used.  Several maps can share a TileManager instance, in which case each map gets its own tile queue, but all maps share the same tile cache.

Summary
OpenLayers.TileManagerProvides queueing of image requests and caching of image elements.
Properties
cacheSize{Number} Number of image elements to keep referenced in this instance’s cache for fast reuse.
tilesPerFrame{Number} Number of queued tiles to load per frame (see frameDelay).
frameDelay{Number} Delay between tile loading frames (see tilesPerFrame) in milliseconds.
moveDelay{Number} Delay in milliseconds after a map’s move event before loading tiles.
zoomDelay{Number} Delay in milliseconds after a map’s zoomend event before loading tiles.
maps{Array(OpenLayers.Map)} The maps to manage tiles on.
tileQueueId{Object} The ids of the drawTilesFromQueue loop, keyed by map id.
tileQueue{Object(Array(OpenLayers.Tile))} Tiles queued for drawing, keyed by map id.
tileCache{Object} Cached image elements, keyed by URL.
tileCacheIndex{Array(String)} URLs of cached tiles.
Constructor
OpenLayers.TileManagerConstructor for a new OpenLayers.TileManager instance.
Functions
addMapBinds this instance to a map
removeMapUnbinds this instance from a map
moveHandles the map’s move event
zoomEndHandles the map’s zoomEnd event
changeLayerHandles the map’s changeLayer event
addLayerHandles the map’s addlayer event
removeLayerHandles the map’s preremovelayer event
handleLayerRefreshClears the cache when a redraw is forced on a layer
updateTimeoutApplies the moveDelay or zoomDelay to the drawTilesFromQueue loop, and schedules more queue processing after frameDelay if there are still tiles in the queue.
addTileListener for the layer’s addtile event
unloadTileListener for the tile’s unload event
queueTileDrawAdds a tile to the queue that will draw it.
drawTilesFromQueueDraws tiles from the tileQueue, and unqueues the tiles
manageTileCacheAdds, updates, removes and fetches cache entries.
addToCache
clearTileQueueClears the tile queue from tiles of a specific layer
destroy

Properties

cacheSize

{Number} Number of image elements to keep referenced in this instance’s cache for fast reuse.  Default is 256.

tilesPerFrame

{Number} Number of queued tiles to load per frame (see frameDelay).  Default is 2.

frameDelay

{Number} Delay between tile loading frames (see tilesPerFrame) in milliseconds.  Default is 16.

moveDelay

{Number} Delay in milliseconds after a map’s move event before loading tiles.  Default is 100.

zoomDelay

{Number} Delay in milliseconds after a map’s zoomend event before loading tiles.  Default is 200.

maps

{Array(OpenLayers.Map)} The maps to manage tiles on.

tileQueueId

{Object} The ids of the drawTilesFromQueue loop, keyed by map id.

tileQueue

{Object(Array(OpenLayers.Tile))} Tiles queued for drawing, keyed by map id.

tileCache

{Object} Cached image elements, keyed by URL.

tileCacheIndex

{Array(String)} URLs of cached tiles.  First entry is the least recently used.

Constructor

OpenLayers.TileManager

Constructor for a new OpenLayers.TileManager instance.

Parameters

options{Object} Configuration for this instance.

Functions

addMap

addMap: function(map)

Binds this instance to a map

Parameters

map{OpenLayers.Map}

removeMap

removeMap: function(map)

Unbinds this instance from a map

Parameters

map{OpenLayers.Map}

move

move: function(evt)

Handles the map’s move event

Parameters

evt{Object} Listener argument

zoomEnd

zoomEnd: function(evt)

Handles the map’s zoomEnd event

Parameters

evt{Object} Listener argument

changeLayer

changeLayer: function(evt)

Handles the map’s changeLayer event

Parameters

evt{Object} Listener argument

addLayer

addLayer: function(evt)

Handles the map’s addlayer event

Parameters

evt{Object} The listener argument

removeLayer

removeLayer: function(evt)

Handles the map’s preremovelayer event

Parameters

evt{Object} The listener argument

handleLayerRefresh

handleLayerRefresh: function(evt)

Clears the cache when a redraw is forced on a layer

Parameters

evt{Object} The listener argument

updateTimeout

updateTimeout: function(map,
delay,
nice)

Applies the moveDelay or zoomDelay to the drawTilesFromQueue loop, and schedules more queue processing after frameDelay if there are still tiles in the queue.

Parameters

map{OpenLayers.Map} The map to update the timeout for
delay{Number} The delay to apply
nice{Boolean} If true, the timeout function will only be created if the tilequeue is not empty.  This is used by the move handler to avoid impacts on dragging performance.  For other events, the tile queue may not be populated yet, so we need to set the timer regardless of the queue size.

addTile

addTile: function(evt)

Listener for the layer’s addtile event

Parameters

evt{Object} The listener argument

unloadTile

unloadTile: function(evt)

Listener for the tile’s unload event

Parameters

evt{Object} The listener argument

queueTileDraw

queueTileDraw: function(evt)

Adds a tile to the queue that will draw it.

Parameters

evt{Object} Listener argument of the tile’s beforedraw event

drawTilesFromQueue

drawTilesFromQueue: function(map)

Draws tiles from the tileQueue, and unqueues the tiles

manageTileCache

manageTileCache: function(evt)

Adds, updates, removes and fetches cache entries.

Parameters

evt{Object} Listener argument of the tile’s beforeload event

addToCache

addToCache: function(evt)

Parameters

evt{Object} Listener argument for the tile’s loadend event

clearTileQueue

clearTileQueue: function(evt)

Clears the tile queue from tiles of a specific layer

Parameters

evt{Object} Listener argument of the layer’s retile event

destroy

destroy: function()
{Number} Delay between tile loading frames (see tilesPerFrame) in milliseconds.
{Number} Number of queued tiles to load per frame (see frameDelay).
Instances of OpenLayers.Map are interactive maps embedded in a web page.
drawTilesFromQueue: function(map)
Draws tiles from the tileQueue, and unqueues the tiles
Constructor for a new OpenLayers.TileManager instance.
addMap: function(map)
Binds this instance to a map
removeMap: function(map)
Unbinds this instance from a map
move: function(evt)
Handles the map’s move event
zoomEnd: function(evt)
Handles the map’s zoomEnd event
changeLayer: function(evt)
Handles the map’s changeLayer event
addLayer: function(evt)
Handles the map’s addlayer event
removeLayer: function(evt)
Handles the map’s preremovelayer event
handleLayerRefresh: function(evt)
Clears the cache when a redraw is forced on a layer
updateTimeout: function(map,
delay,
nice)
Applies the moveDelay or zoomDelay to the drawTilesFromQueue loop, and schedules more queue processing after frameDelay if there are still tiles in the queue.
{Number} Delay in milliseconds after a map’s move event before loading tiles.
{Number} Delay in milliseconds after a map’s zoomend event before loading tiles.
addTile: function(evt)
Listener for the layer’s addtile event
unloadTile: function(evt)
Listener for the tile’s unload event
queueTileDraw: function(evt)
Adds a tile to the queue that will draw it.
manageTileCache: function(evt)
Adds, updates, removes and fetches cache entries.
addToCache: function(evt)
clearTileQueue: function(evt)
Clears the tile queue from tiles of a specific layer
destroy: function()
Close