OpenLayers.Tile.Image

Instances of OpenLayers.Tile.Image are used to manage the image tiles used by various layers.  Create a new image tile with the OpenLayers.Tile.Image constructor.

Inherits from

Summary
OpenLayers.Tile.ImageInstances of OpenLayers.Tile.Image are used to manage the image tiles used by various layers.
Properties
url{String} The URL of the image being requested.
imgDiv{DOMElement} The div element which wraps the image.
frame{DOMElement} The image element is appended to the frame.
layerAlphaHack{Boolean} True if the png alpha hack needs to be applied on the layer’s div.
isBackBuffer{Boolean} Is this tile a back buffer tile?
lastRatio{Float} Used in transition code only.
isFirstDraw{Boolean} Is this the first time the tile is being drawn? 
backBufferTile{OpenLayers.Tile} A clone of the tile used to create transition effects when the tile is moved or changes resolution.
Functions
destroynullify references to prevent circular references and memory leaks
clone
drawCheck that a tile should be drawn, and draw it.
resetBackBufferTriggered by two different events, layer loadend, and tile loadend.
renderTileInternal function to actually initialize the image tile, position it correctly, and set its url.
positionImageUsing the properties currenty set on the layer, position the tile correctly.
clearClear the tile of any bounds/position-related data so that it can be reused in a new location.
initImgDivCreates the imgDiv property on the tile.
checkImgURLMake sure that the image that just loaded is the one this tile is meant to display, since panning/zooming might have changed the tile’s URL in the meantime.
startTransitionThis method is invoked on tiles that are backBuffers for tiles in the grid.
showShow the tile by showing its frame.
hideHide the tile by hiding its frame.

Properties

url

{String} The URL of the image being requested.  No default.  Filled in by layer.getURL() function.

imgDiv

{DOMElement} The div element which wraps the image.

frame

{DOMElement} The image element is appended to the frame.  Any gutter on the image will be hidden behind the frame.

layerAlphaHack

{Boolean} True if the png alpha hack needs to be applied on the layer’s div.

isBackBuffer

{Boolean} Is this tile a back buffer tile?

lastRatio

{Float} Used in transition code only.  This is the previous ratio of the back buffer tile resolution to the map resolution.  Compared with the current ratio to determine if zooming occurred.

isFirstDraw

{Boolean} Is this the first time the tile is being drawn?  This is used to force resetBackBuffer to synchronize the backBufferTile with the foreground tile the first time the foreground tile loads so that if the user zooms before the layer has fully loaded, the backBufferTile for tiles that have been loaded can be used.

backBufferTile

{OpenLayers.Tile} A clone of the tile used to create transition effects when the tile is moved or changes resolution.

Functions

destroy

destroy: function()

nullify references to prevent circular references and memory leaks

clone

clone: function (obj)

Parameters

obj{OpenLayers.Tile.Image} The tile to be cloned

Returns

{OpenLayers.Tile.Image} An exact clone of this OpenLayers.Tile.Image

draw

draw: function()

Check that a tile should be drawn, and draw it.

Returns

{Boolean} Always returns true.

resetBackBuffer

resetBackBuffer: function()

Triggered by two different events, layer loadend, and tile loadend.  In any of these cases, we check to see if we can hide the backBufferTile yet and update its parameters to match the foreground tile.

Basic logic

  • If the backBufferTile hasn’t been drawn yet, reset it
  • If layer is still loading, show foreground tile but don’t hide the backBufferTile yet
  • If layer is done loading, reset backBuffer tile and show foreground tile

renderTile

renderTile: function()

Internal function to actually initialize the image tile, position it correctly, and set its url.

positionImage

positionImage: function()

Using the properties currenty set on the layer, position the tile correctly.  This method is used both by the async and non-async versions of the Tile.Image code.

clear

clear: function()

Clear the tile of any bounds/position-related data so that it can be reused in a new location.

initImgDiv

initImgDiv: function()

Creates the imgDiv property on the tile.

checkImgURL

checkImgURL: function ()

Make sure that the image that just loaded is the one this tile is meant to display, since panning/zooming might have changed the tile’s URL in the meantime.  If the tile URL did change before the image loaded, set the imgDiv display to ‘none’, as either (a) it will be reset to visible when the new URL loads in the image, or (b) we don’t want to display this tile after all because its new bounds are outside our maxExtent.

This function should no longer be neccesary with the improvements to Grid.js in OpenLayers 2.3.  The lack of a good isEquivilantURL function caused problems in 2.2, but it’s possible that with the improved isEquivilant URL function, this might be neccesary at some point.

See discussion in the thread at http://openlayers.org/pipermail/dev/2007-January/000205.html

startTransition

startTransition: function()

This method is invoked on tiles that are backBuffers for tiles in the grid.  The grid tile is about to be cleared and a new tile source loaded.  This is where the transition effect needs to be started to provide visual continuity.

show

show: function()

Show the tile by showing its frame.

hide

hide: function()

Hide the tile by hiding its frame.

This is a class designed to designate a single tile, however it is explicitly designed to do relatively little.
destroy: function()
nullify references to prevent circular references and memory leaks
clone: function (obj)
draw: function()
Check that a tile should be drawn, and draw it.
resetBackBuffer: function()
Triggered by two different events, layer loadend, and tile loadend.
renderTile: function()
Internal function to actually initialize the image tile, position it correctly, and set its url.
positionImage: function()
Using the properties currenty set on the layer, position the tile correctly.
clear: function()
Clear the tile of any bounds/position-related data so that it can be reused in a new location.
initImgDiv: function()
Creates the imgDiv property on the tile.
checkImgURL: function ()
Make sure that the image that just loaded is the one this tile is meant to display, since panning/zooming might have changed the tile’s URL in the meantime.
startTransition: function()
This method is invoked on tiles that are backBuffers for tiles in the grid.
show: function()
Show the tile by showing its frame.
hide: function()
Hide the tile by hiding its frame.
Instances of OpenLayers.Tile.Image are used to manage the image tiles used by various layers.
Close