OpenLayers.Layer.Grid

Base class for layers that use a lattice of tiles.  Create a new grid layer with the OpenLayers.Layer.Grid constructor.

Inherits from

Summary
OpenLayers.Layer.GridBase 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.Layer.GridCreate a new grid layer
Functions
removeMapCalled when the layer is removed from the map.
destroyDeconstruct the layer and clear the grid.
clearGridGo through and remove all tiles from the grid, calling destroy() on each of them to kill circular references
cloneCreate a clone of this layer
moveToThis function is called whenever the map is moved.
moveByPxMove the layer based on pixel vector.
scheduleMoveGriddedTilesSchedule the move of tiles.
setTileSizeCheck 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).
getGridBoundsDeprecated.
getTilesBoundsReturn the bounds of the tile grid.
initSingleTile
calculateGridLayoutGenerate parameters for the grid layout.
getTileOriginDetermine the origin for aligning the grid of tiles.
initGriddedTiles
getMaxExtentGet this layer’s maximum extent.
spiralTileLoadStarts 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.
addTileCreate a tile, initialize it, and add it to the layer div.
addTileMonitoringHooksThis 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.
removeTileMonitoringHooksThis function takes a tile as input and removes the tile hooks that were added in addTileMonitoringHooks()
moveGriddedTiles
shiftRowShifty grid work
shiftColumnShift grid work in the other dimension
removeExcessTilesWhen the size of the map or the buffer changes, we may need to remove some excess rows and columns.
onMapResizeFor singleTile layers, this will set a new tile size according to the dimensions of the map pane.
getTileBoundsReturns The tile bounds for a layer given a pixel location.

Properties

tileSize

tileOriginCorner

{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”.

tileOrigin

{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``.

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.  The tile’s size will be determined by the ‘ratio’ property.  When the tile is dragged such that it does not cover the entire viewport, it is reloaded.

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.  For very slow loading layers, a larger value may increase performance somewhat when dragging, but will increase bandwidth use significantly.

numLoadingTiles

{Integer} How many tiles are still loading?

tileLoadingDelay

{Integer}Number of milliseconds before we shift and load tiles.  Default is 100.

timerId

{Number}The id of the tileLoadingDelay timer.

Constructor

OpenLayers.Layer.Grid

Create a new grid layer

Parameters

name{String}
url{String}
params{Object}
options{Object} Hashtable of extra options to tag onto the layer

Functions

removeMap

removeMap: function(map)

Called when the layer is removed from the map.

Parameters

map{OpenLayers.Map} The map.

destroy

destroy: function()

Deconstruct the layer and clear the grid.

clearGrid

clearGrid:function()

Go through and remove all tiles from the grid, calling destroy() on each of them to kill circular references

clone

clone: function (obj)

Create a clone of this layer

Parameters

obj{Object} Is this ever used?

Returns

{OpenLayers.Layer.Grid} An exact clone of this OpenLayers.Layer.Grid

moveTo

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.

Parameters

bounds{OpenLayers.Bounds}
zoomChanged{Boolean}
dragging{Boolean}

moveByPx

moveByPx: function(dx,
dy)

Move the layer based on pixel vector.

Parameters

dx{Number}
dy{Number}

scheduleMoveGriddedTiles

scheduleMoveGriddedTiles: function()

Schedule the move of tiles.

setTileSize

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).

Parameters

size{OpenLayers.Size}

getGridBounds

getGridBounds: function()

Deprecated.  This function will be removed in 3.0.  Please use getTilesBounds() instead.

Returns

{OpenLayers.Bounds} A Bounds object representing the bounds of all the currently loaded tiles (including those partially or not at all seen onscreen)

getTilesBounds

getTilesBounds: function()

Return the bounds of the tile grid.

Returns

{OpenLayers.Bounds} A Bounds object representing the bounds of all the currently loaded tiles (including those partially or not at all seen onscreen).

initSingleTile

initSingleTile: function(bounds)

Parameters

bounds{OpenLayers.Bounds}

calculateGridLayout

calculateGridLayout: function(bounds,
origin,
resolution)

Generate parameters for the grid layout.

Parameters

bounds{<OpenLayers.Bound>}
origin{OpenLayers.LonLat}
resolution{Number}

Returns

Object containing properties tilelon, tilelat, tileoffsetlat, tileoffsetlat, tileoffsetx, tileoffsety

getTileOrigin

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.

Returns

{OpenLayers.LonLat} The tile origin.

initGriddedTiles

initGriddedTiles:function(bounds)

Parameters

bounds{OpenLayers.Bounds}

getMaxExtent

getMaxExtent: function()

Get this layer’s maximum extent.  (Implemented as a getter for potential specific implementations in sub-classes.)

Returns

{OpenLayers.Bounds}

spiralTileLoad

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

addTile:function(bounds,
position)

Create a tile, initialize it, and add it to the layer div.

Parameters bounds - {OpenLayers.Bounds} position - {OpenLayers.Pixel}

Returns

{OpenLayers.Tile} The added OpenLayers.Tile

addTileMonitoringHooks

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.

Parameters

tile{OpenLayers.Tile}

removeTileMonitoringHooks

removeTileMonitoringHooks: function(tile)

This function takes a tile as input and removes the tile hooks that were added in addTileMonitoringHooks()

Parameters

tile{OpenLayers.Tile}

moveGriddedTiles

moveGriddedTiles: function()

shiftRow

shiftRow:function(prepend)

Shifty grid work

Parameters

prepend{Boolean} if true, prepend to beginning. if false, then append to end

shiftColumn

shiftColumn: function(prepend)

Shift grid work in the other dimension

Parameters

prepend{Boolean} if true, prepend to beginning. if false, then append to end

removeExcessTiles

removeExcessTiles: function(rows,
columns)

When the size of the map or the buffer changes, we may need to remove some excess rows and columns.

Parameters

rows{Integer} Maximum number of rows we want our grid to have.
columns{Integer} Maximum number of columns we want our grid to have.

onMapResize

onMapResize: function()

For singleTile layers, this will set a new tile size according to the dimensions of the map pane.

getTileBounds

getTileBounds: function(viewPortPx)

Returns The tile bounds for a layer given a pixel location.

Parameters

viewPortPx{OpenLayers.Pixel} The location in the viewport.

Returns

{OpenLayers.Bounds} Bounds of the tile at the given pixel location.

Instances of this class represent a width/height pair
{OpenLayers.LonLat} Optional origin for aligning the grid of tiles.
{OpenLayers.Bounds} The center of these bounds will not stray outside of the viewport extent during panning.
This class represents a longitude and latitude pair
This is a class designed to designate a single tile, however it is explicitly designed to do relatively little.
removeMap: function(map)
Called when the layer is removed from the map.
destroy: function()
Deconstruct the layer and clear the grid.
clearGrid:function()
Go through and remove all tiles from the grid, calling destroy() on each of them to kill circular references
clone: function (obj)
Create a clone of this layer
moveTo:function(bounds,
zoomChanged,
dragging)
This function is called whenever the map is moved.
moveByPx: function(dx,
dy)
Move the layer based on pixel vector.
scheduleMoveGriddedTiles: function()
Schedule the move of tiles.
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).
getGridBounds: function()
Deprecated.
getTilesBounds: function()
Return the bounds of the tile grid.
initSingleTile: function(bounds)
calculateGridLayout: function(bounds,
origin,
resolution)
Generate parameters for the grid layout.
getTileOrigin: function()
Determine the origin for aligning the grid of tiles.
initGriddedTiles:function(bounds)
getMaxExtent: function()
Get this layer’s maximum extent.
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.
addTile:function(bounds,
position)
Create a tile, initialize it, and add it to the layer div.
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.
removeTileMonitoringHooks: function(tile)
This function takes a tile as input and removes the tile hooks that were added in addTileMonitoringHooks()
moveGriddedTiles: function()
shiftRow:function(prepend)
Shifty grid work
shiftColumn: function(prepend)
Shift grid work in the other dimension
removeExcessTiles: function(rows,
columns)
When the size of the map or the buffer changes, we may need to remove some excess rows and columns.
onMapResize: function()
For singleTile layers, this will set a new tile size according to the dimensions of the map pane.
getTileBounds: function(viewPortPx)
Returns The tile bounds for a layer given a pixel location.
Create a new grid layer
Instances of OpenLayers.Map are interactive maps embedded in a web page.
Instances of this class represent bounding boxes.
{String} If the tileOrigin property is not provided, the tile origin will be derived from the layer’s maxExtent.
This class represents a screen coordinate, in x and y coordinates
Close