Instances of ALKMaps.Tile.Image are used to manage the image tiles used by various layers. Create a new image tile with the ALKMaps.Tile.Image constructor.
ALKMaps. | Instances of ALKMaps.Tile.Image are used to manage the image tiles used by various layers. |
Properties | |
url | {String} The URL of the image being requested. |
imgDiv | {HTMLImageElement} The image for this tile. |
frame | {DOMElement} The image element is appended to the frame. |
imageReloadAttempts | {Integer} Attempts to load the image. |
layerAlphaHack | {Boolean} True if the png alpha hack needs to be applied on the layer’s div. |
asyncRequestId | {Integer} ID of an request to see if request is still valid. |
blankImageUrl | {String} Using a data scheme url is not supported by all browsers, but we don’t care because we either set it as css backgroundImage, or the image’s display style is set to “none” when we use it. |
maxGetUrlLength | {Number} If set, requests that would result in GET urls with more characters than the number provided will be made using form-encoded HTTP POST. |
canvasContext | {CanvasRenderingContext2D} A canvas context associated with the tile image. |
crossOriginKeyword | The value of the crossorigin keyword to use when loading images. |
Constructor | |
ALKMaps. | Constructor for a new ALKMaps.Tile.Image instance. |
Functions | |
destroy | nullify references to prevent circular references and memory leaks |
draw | Check that a tile should be drawn, and draw it. |
renderTile | Internal function to actually initialize the image tile, position it correctly, and set its url. |
positionTile | Using the properties currently set on the layer, position the tile correctly. |
clear | Remove the tile from the DOM, clear it of any image related data so that it can be reused in a new location. |
getImage | Returns or creates and returns the tile image. |
initImage | Creates the content for the frame on the tile. |
setImgSrc | Sets the source for the tile image |
getTile | Get the tile’s markup. |
createBackBuffer | Create a backbuffer for this tile. |
onImageLoad | Handler for the image onload event |
onImageError | Handler for the image onerror event |
getCanvasContext | Returns a canvas context associated with the tile image (with the image drawn on it). |
{Number} If set, requests that would result in GET urls with more characters than the number provided will be made using form-encoded HTTP POST. It is good practice to avoid urls that are longer than 2048 characters.
Older versions of Gecko based browsers (e.g. Firefox < 3.5) and most Opera versions do not fully support this option. On all browsers, transition effects are not supported if POST requests are used.
The value of the crossorigin keyword to use when loading images. This is only relevant when using getCanvasContext for tiles from remote origins and should be set to either ‘anonymous’ or ‘use-credentials’ for servers that send Access-Control-Allow-Origin headers with their tiles.
Constructor for a new ALKMaps.Tile.Image instance.
layer | {ALKMaps.Layer} layer that the tile will go in. |
position | {ALKMaps.Pixel} |
bounds | {ALKMaps.Bounds} |
url | {String} |
size | {ALKMaps.Size} |
options | {Object} |
createBackBuffer: function()
Create a backbuffer for this tile. A backbuffer isn’t exactly a clone of the tile’s markup, because we want to avoid the reloading of the image. So we clone the frame, and steal the image from the tile.
{DOMElement} The markup, or undefined if the tile has no image or if it’s currently loading.
getCanvasContext: function()
Returns a canvas context associated with the tile image (with the image drawn on it). Returns undefined if the browser does not support canvas, if the tile has no image or if it’s currently loading.
The function returns a canvas context instance but the underlying canvas is still available in the ‘canvas’ property:
var context = tile.getCanvasContext(); if (context) { var data = context.canvas.toDataURL('image/jpeg'); }
{Boolean}
nullify references to prevent circular references and memory leaks
destroy: function()
Check that a tile should be drawn, and draw it.
draw: function()
Internal function to actually initialize the image tile, position it correctly, and set its url.
renderTile: function()
Using the properties currently set on the layer, position the tile correctly.
positionTile: function()
Remove the tile from the DOM, clear it of any image related data so that it can be reused in a new location.
clear: function()
Returns or creates and returns the tile image.
getImage: function()
Creates the content for the frame on the tile.
initImage: function()
Sets the source for the tile image
setImgSrc: function( url )
Get the tile’s markup.
getTile: function()
Create a backbuffer for this tile.
createBackBuffer: function()
Handler for the image onload event
onImageLoad: function()
Handler for the image onerror event
onImageError: function()
Returns a canvas context associated with the tile image (with the image drawn on it).
getCanvasContext: function()