OpenLayers.Tile.Image - OpenLayers

# 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

- OpenLayers.Tile

Summary

OpenLayers.Tile.Image | Instances of OpenLayers.Tile.Image are used to manage the image tiles used by various layers.
Properties |
events | {OpenLayers.Events} An events object that handles all events on the tile.
url | {String} The URL of the image being requested.
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.
crossOriginKeyword | The value of the crossorigin keyword to use when loading images.
Constructor |
OpenLayers.Tile.Image | Constructor for a new OpenLayers.Tile.Image instance.
Functions |
destroy | nullify references to prevent circular references and memory leaks
setImage | Sets the image element for this tile.
getCanvasContext | Returns a canvas context associated with the tile image (with the image drawn on it).
Constants |
OpenLayers.Tile.Image.IMAGE | {HTMLImageElement} The image for a tile.

### Properties

### events

{OpenLayers.Events} An events object that handles all events on the tile.

#### Register a listener for a particular event with the following syntax

>     tile.events.register(type, obj, listener);

#### Supported event types (in addition to the OpenLayers.Tile events)

beforeload | Triggered before an image is prepared for loading, when the url for the image is known already. Listeners may call setImage on the tile instance. If they do so, that image will be used and no new one will be created.

### url

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

### 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. It is good practice to avoid urls that are longer than 2048 characters.

#### Caution

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.

### crossOriginKeyword

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

### OpenLayers.Tile.Image

Constructor for a new OpenLayers.Tile.Image instance.

#### Parameters

layer | {OpenLayers.Layer} layer that the tile will go in.
position | {OpenLayers.Pixel}
bounds | {OpenLayers.Bounds}
url | {String} Deprecated. Remove me in 3.0.
size | {OpenLayers.Size}
options | {Object}

### Functions

### destroy

> destroy: function()

nullify references to prevent circular references and memory leaks

### setImage

> setImage: function( | img | )

Sets the image element for this tile. This method should only be called from beforeload listeners.

Parameters img - {HTMLImageElement} The image to use for this tile.

### getCanvasContext

> 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');
>     }

#### Returns

{Boolean}

### Constants

### OpenLayers.Tile.Image.IMAGE

{HTMLImageElement} The image for a tile.

Constructor for a new OpenLayers.Tile.Image instance.

> destroy: function()

nullify references to prevent circular references and memory leaks

> setImage: function( | img | )

Sets the image element for this tile.

> getCanvasContext: function()

Returns a canvas context associated with the tile image (with the image drawn on it).
This class represents a screen coordinate, in x and y coordinates
Instances of this class represent bounding boxes.
Contains convenience functions for string manipulation.
Instances of this class represent a width/height pair
Close