Class: tile

geo. tile

new geo.tile(spec){geo.tile}

This class defines the raw interface for a "tile" on a map. A tile is defined as a rectangular section of a map. The base implementation is independent of the actual content of the tile, but assumes that the content is loaded asynchronously via a url. The tile object has a promise-like interface.

Name Type Description
spec geo.tile.spec

The tile specification.

Returns:
Type Description
geo.tile
Example
tile.then(function (data) {...}).catch(function (data) {...});

Type Definitions

geo.tile.specobject

Properties:
Name Type Argument Description
index object

The global position of the tile.

Properties
Name Type Description
x number

The x-coordinate (usually the column number).

y number

The y-coordinate (usually the row number).

size object

The size of each tile.

Properties
Name Type Description
x number

Width (usually in pixels).

y number

Height (usually in pixels).

url object | string

A url or jQuery ajax config object.

overlap object <optional>

The size of overlap with neighboring tiles.

Properties
Name Type Default Description
x number 0
y number 0

Members

bottom

Computes the global coordinates of the bottom edge.

Properties:
Name Type Description
bottom number

The global coordinates of the bottom edge.

index

Return the index coordinates. Read only.

Properties:
Name Type Description
index object

The tile index.

Properties
Name Type Description
x number

The tile x index.

y number

The tile y index.

left

Computes the global coordinates of the left edge.

Properties:
Name Type Description
left number

The global coordinates of the left edge.

overlap

Return the tile overlap. Read only.

Properties:
Name Type Description
overlap object

The tile overlap.

Properties
Name Type Description
x number

The tile x overlap.

y number

The tile y overlap.

Computes the global coordinates of the right edge.

Properties:
Name Type Description
right number

The global coordinates of the right edge.

size

Return the tile size. Read only.

Properties:
Name Type Description
size object

The tile size.

Properties
Name Type Description
x number

The tile width.

y number

The tile height.

top

Computes the global coordinates of the top edge.

Properties:
Name Type Description
top number

The global coordinates of the top edge.

Methods

bounds(index, shift){object}

Return the bounds of the tile given an index offset and a translation.

Name Type Description
index object

The tile index containing (0, 0).

shift object

The coordinates of (0, 0) inside the tile.

Returns:
Type Description
object An object with left, top, right, bottom.

catch(method){this}

Add a method to be called with the data when the ajax fails.

Name Type Description
method function

The rejection handler.

Returns:
Type Description
this

fadeIn(duration){this}

Set the opacity of the tile to 0 and gradually fade in over the given number of milliseconds. This is just a delay.

Name Type Description
duration number

The duration of the animation in ms.

Returns:
Type Description
this

fetch(){this}

Initiate the ajax request and add a promise interface to the tile object. This method exists to allow derived classes the ability to override how the tile is obtained. For example, imageTile uses an Image element rather than $.get.

Returns:
Type Description
this

fetched(){boolean}

Return whether this tile has been fetched already.

Returns:
Type Description
boolean True if the tile has been fetched.

then(onSuccess, onFailure){this}

Add a method to be called with the data when the ajax request is successfully resolved.

Name Type Description
onSuccess function nullable

The success handler.

onFailure function nullable

The failure handler.

Returns:
Type Description
this

toString(){string}

Return a unique string representation of the given tile useable as a hash key. Possibly extend later to include url information to make caches aware of the tile source.

Returns:
Type Description
string