Base class for layers that use a lattice of tiles. Create a new grid layer with the OpenLayers.Layer.Grid constructor.
OpenLayers. | Base class for layers that use a lattice of tiles. |
Properties | |
tileSize | {OpenLayers.Size} |
tileOriginCorner | {String} If the tileOrigin property is not provided, the tile origin will be derived from the layer’s maxExtent. |
tileOrigin | {OpenLayers.LonLat} Optional origin for aligning the grid of tiles. |
tileOptions | {Object} optional configuration options for OpenLayers.Tile instances created by this Layer, if supported by the tile class. |
grid | {Array(Array(OpenLayers.Tile))} This is an array of rows, each row is an array of tiles. |
singleTile | {Boolean} Moves the layer into single-tile mode, meaning that one tile will be loaded. |
ratio | {Float} Used only when in single-tile mode, this specifies the ratio of the size of the single tile to the size of the map. |
buffer | {Integer} Used only when in gridded mode, this specifies the number of extra rows and colums of tiles on each side which will surround the minimum grid tiles to cover the map. |
numLoadingTiles | {Integer} How many tiles are still loading? |
tileLoadingDelay | |
timerId | |
Constructor | |
OpenLayers. | Create a new grid layer |
Functions | |
removeMap | Called when the layer is removed from the map. |
destroy | Deconstruct the layer and clear the grid. |
clearGrid | Go through and remove all tiles from the grid, calling destroy() on each of them to kill circular references |
clone | Create a clone of this layer |
moveTo | This function is called whenever the map is moved. |
moveByPx | Move the layer based on pixel vector. |
scheduleMoveGriddedTiles | Schedule the move of tiles. |
setTileSize | Check if we are in singleTile mode and if so, set the size as a ratio of the map size (as specified by the layer’s ‘ratio’ property). |
getGridBounds | Deprecated. |
getTilesBounds | Return the bounds of the tile grid. |
initSingleTile | |
calculateGridLayout | Generate parameters for the grid layout. |
getTileOrigin | Determine the origin for aligning the grid of tiles. |
initGriddedTiles | |
getMaxExtent | Get this layer’s maximum extent. |
spiralTileLoad | Starts at the top right corner of the grid and proceeds in a spiral towards the center, adding tiles one at a time to the beginning of a queue. |
addTile | Create a tile, initialize it, and add it to the layer div. |
addTileMonitoringHooks | This function takes a tile as input and adds the appropriate hooks to the tile so that the layer can keep track of the loading tiles. |
removeTileMonitoringHooks | This function takes a tile as input and removes the tile hooks that were added in addTileMonitoringHooks() |
moveGriddedTiles | |
shiftRow | Shifty grid work |
shiftColumn | Shift grid work in the other dimension |
removeExcessTiles | When the size of the map or the buffer changes, we may need to remove some excess rows and columns. |
onMapResize | For singleTile layers, this will set a new tile size according to the dimensions of the map pane. |
getTileBounds | Returns The tile bounds for a layer given a pixel location. |
{String} If the tileOrigin property is not provided, the tile origin will be derived from the layer’s maxExtent. The corner of the maxExtent used is determined by this property. Acceptable values are “tl” (top left), “tr” (top right), “bl” (bottom left), and “br” (bottom right). Default is “bl”.
{OpenLayers.LonLat} Optional origin for aligning the grid of tiles. If provided, requests for tiles at all resolutions will be aligned with this location (no tiles shall overlap this location). If not provided, the grid of tiles will be aligned with the layer’s maxExtent. Default is ``null``.
{Object} optional configuration options for OpenLayers.Tile instances created by this Layer, if supported by the tile class.
{Array(Array(OpenLayers.Tile))} This is an array of rows, each row is an array of tiles.
{Integer} Used only when in gridded mode, this specifies the number of extra rows and colums of tiles on each side which will surround the minimum grid tiles to cover the map. For very slow loading layers, a larger value may increase performance somewhat when dragging, but will increase bandwidth use significantly.
removeMap: function( map )
Called when the layer is removed from the map.
map | {OpenLayers.Map} The map. |
clone: function ( obj )
Create a clone of this layer
obj | {Object} Is this ever used? |
{OpenLayers.Layer.Grid} An exact clone of this OpenLayers.Layer.Grid
moveTo:function( bounds, zoomChanged, dragging )
This function is called whenever the map is moved. All the moving of actual ‘tiles’ is done by the map, but moveTo’s role is to accept a bounds and make sure the data that that bounds requires is pre-loaded.
bounds | {OpenLayers.Bounds} |
zoomChanged | {Boolean} |
dragging | {Boolean} |
setTileSize: function( size )
Check if we are in singleTile mode and if so, set the size as a ratio of the map size (as specified by the layer’s ‘ratio’ property).
size | {OpenLayers.Size} |
getGridBounds: function()
Deprecated. This function will be removed in 3.0. Please use getTilesBounds() instead.
{OpenLayers.Bounds} A Bounds object representing the bounds of all the currently loaded tiles (including those partially or not at all seen onscreen)
getTilesBounds: function()
Return the bounds of the tile grid.
{OpenLayers.Bounds} A Bounds object representing the bounds of all the currently loaded tiles (including those partially or not at all seen onscreen).
calculateGridLayout: function( bounds, origin, resolution )
Generate parameters for the grid layout.
bounds | {<OpenLayers.Bound>} |
origin | {OpenLayers.LonLat} |
resolution | {Number} |
Object containing properties tilelon, tilelat, tileoffsetlat, tileoffsetlat, tileoffsetx, tileoffsety
getTileOrigin: function()
Determine the origin for aligning the grid of tiles. If a tileOrigin property is supplied, that will be returned. Otherwise, the origin will be derived from the layer’s maxExtent property. In this case, the tile origin will be the corner of the maxExtent given by the tileOriginCorner property.
{OpenLayers.LonLat} The tile origin.
spiralTileLoad: function()
Starts at the top right corner of the grid and proceeds in a spiral towards the center, adding tiles one at a time to the beginning of a queue.
Once all the grid’s tiles have been added to the queue, we go back and iterate through the queue (thus reversing the spiral order from outside-in to inside-out), calling draw() on each tile.
addTile:function( bounds, position )
Create a tile, initialize it, and add it to the layer div.
Parameters bounds - {OpenLayers.Bounds} position - {OpenLayers.Pixel}
{OpenLayers.Tile} The added OpenLayers.Tile
addTileMonitoringHooks: function( tile )
This function takes a tile as input and adds the appropriate hooks to the tile so that the layer can keep track of the loading tiles.
tile | {OpenLayers.Tile} |
removeTileMonitoringHooks: function( tile )
This function takes a tile as input and removes the tile hooks that were added in addTileMonitoringHooks()
tile | {OpenLayers.Tile} |
getTileBounds: function( viewPortPx )
Returns The tile bounds for a layer given a pixel location.
viewPortPx | {OpenLayers.Pixel} The location in the viewport. |
{OpenLayers.Bounds} Bounds of the tile at the given pixel location.
Called when the layer is removed from the map.
removeMap: function( map )
Deconstruct the layer and clear the grid.
destroy: function()
Go through and remove all tiles from the grid, calling destroy() on each of them to kill circular references
clearGrid:function()
Create a clone of this layer
clone: function ( obj )
This function is called whenever the map is moved.
moveTo:function( bounds, zoomChanged, dragging )
Move the layer based on pixel vector.
moveByPx: function( dx, dy )
Schedule the move of tiles.
scheduleMoveGriddedTiles: function()
Check if we are in singleTile mode and if so, set the size as a ratio of the map size (as specified by the layer’s ‘ratio’ property).
setTileSize: function( size )
Deprecated.
getGridBounds: function()
Return the bounds of the tile grid.
getTilesBounds: function()
initSingleTile: function( bounds )
Generate parameters for the grid layout.
calculateGridLayout: function( bounds, origin, resolution )
Determine the origin for aligning the grid of tiles.
getTileOrigin: function()
initGriddedTiles:function( bounds )
Get this layer’s maximum extent.
getMaxExtent: function()
Starts at the top right corner of the grid and proceeds in a spiral towards the center, adding tiles one at a time to the beginning of a queue.
spiralTileLoad: function()
Create a tile, initialize it, and add it to the layer div.
addTile:function( bounds, position )
This function takes a tile as input and adds the appropriate hooks to the tile so that the layer can keep track of the loading tiles.
addTileMonitoringHooks: function( tile )
This function takes a tile as input and removes the tile hooks that were added in addTileMonitoringHooks()
removeTileMonitoringHooks: function( tile )
moveGriddedTiles: function()
Shifty grid work
shiftRow:function( prepend )
Shift grid work in the other dimension
shiftColumn: function( prepend )
When the size of the map or the buffer changes, we may need to remove some excess rows and columns.
removeExcessTiles: function( rows, columns )
For singleTile layers, this will set a new tile size according to the dimensions of the map pane.
onMapResize: function()
Returns The tile bounds for a layer given a pixel location.
getTileBounds: function( viewPortPx )