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} |
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. |
tileClass | {OpenLayers.Tile} The tile class to use for this layer. |
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. |
transitionEffect | {String} The transition effect to use when the map is zoomed. |
numLoadingTiles | {Integer} How many tiles are still loading? |
removeBackBufferDelay | {Number} Delay for removing the backbuffer when all tiles have finished loading. |
className | {String} Name of the class added to the layer div. |
Constructor | |
OpenLayers.
|
Create a new grid layer |
Functions | |
destroy | Deconstruct the layer and clear the grid. |
mergeNewParams | Refetches tiles with new params merged, keeping a backbuffer. |
addOptions | |
clone | Create a clone of this layer |
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). |
getTilesBounds | Return the bounds of the tile grid. |
addTile | Create a tile, initialize it, and add it to the layer div. |
getTileBounds | Returns The tile bounds for a layer given a pixel location. |
{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.
{OpenLayers.Tile} The tile class to use for this layer. Defaults is OpenLayers.Tile.Image.
{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.
{String} The transition effect to use when the map is zoomed. Two posible values:
”resize” | Existing tiles are resized on zoom to provide a visual effect of the zoom having taken place immediately. As the new tiles become available, they are drawn on top of the resized tiles (this is the default setting). |
”map-resize” | Existing tiles are resized on zoom and placed below the base layer. New tiles for the base layer will cover existing tiles. This setting is recommended when having an overlay duplicated during the transition is undesirable (e.g. street labels or big transparent fills). |
null | No transition effect. |
Using “resize” on non-opaque layers can cause undesired visual effects. Set transitionEffect to null in this case.
{Number} Delay for removing the backbuffer when all tiles have finished loading. Can be set to 0 when no css opacity transitions for the olTileImage class are used. Default is 0 for singleTile layers, 2500 for tiled layers. See className for more information on tile animation.
{String} Name of the class added to the layer div. If not set in the options passed to the constructor then className defaults to “olLayerGridSingleTile” for single tile layers (see singleTile), and “olLayerGrid” for non single tile layers.
The displaying of tiles is not animated by default for single tile layers - OpenLayers’ default theme (style.css) includes this:
.olLayerGrid .olTileImage { -webkit-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear; transition: opacity 0.2s linear; }
To animate tile displaying for any grid layer the following CSS rule can be used:
.olTileImage { -webkit-transition: opacity 0.2s linear; -moz-transition: opacity 0.2s linear; -o-transition: opacity 0.2s linear; transition: opacity 0.2s linear; }
In that case, to avoid flash effects, removeBackBufferDelay should not be zero.
Refetches tiles with new params merged, keeping a backbuffer. Each loading new tile will have a css class of ‘.olTileReplacing’. If a stylesheet applies a ‘display: none’ style to that class, any fade-in transition will not apply, and backbuffers for each tile will be removed as soon as the tile is loaded.
newParams | {Object} |
redrawn: {Boolean} whether the layer was actually redrawn.
addOptions: function ( newOptions, reinitialize )
newOptions | {Object} |
reinitialize | {Boolean} If set to true, and if resolution options of the current baseLayer were changed, the map will be recentered to make sure that it is displayed with a valid resolution, and a changebaselayer event will be triggered. |
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
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} |
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).
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
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.
Deconstruct the layer and clear the grid.
destroy: function()
addOptions: function ( newOptions, reinitialize )
Create a clone of this layer
clone: function ( obj )
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 )
Return the bounds of the tile grid.
getTilesBounds: function()
Create a tile, initialize it, and add it to the layer div.
addTile: function( bounds, position )
Returns The tile bounds for a layer given a pixel location.
getTileBounds: function( viewPortPx )