ALKMaps.Tile

This is a class designed to designate a single tile, however it is explicitly designed to do relatively little.  Tiles store information about themselves -- such as the URL that they are related to, and their size - but do not add themselves to the layer div automatically, for example.  Create a new tile with the ALKMaps.Tile constructor, or a subclass.

TBD 3.0remove reference to url in above paragraph
Summary
ALKMaps.TileThis is a class designed to designate a single tile, however it is explicitly designed to do relatively little.
Properties
events{ALKMaps.Events} An events object that handles all events on the tile.
eventListeners{Object} If set as an option at construction, the eventListeners object will be registered with ALKMaps.Events.on.
id{String} null
layer{ALKMaps.Layer} layer the tile is attached to
url{String} url of the request.
bounds{ALKMaps.Bounds} null
size{ALKMaps.Size} null
position{ALKMaps.Pixel} Top Left pixel of the tile
isLoading{Boolean} Is the tile loading?
Constructor
ALKMaps.TileConstructor for a new ALKMaps.Tile instance.
Functions
unloadCall immediately before destroying if you are listening to tile events, so that counters are properly handled if tile is still loading at destroy-time.
destroyNullify references to prevent circular references and memory leaks.
drawClear whatever is currently in the tile, then return whether or not it should actually be re-drawn.
shouldDrawReturn whether or not the tile should actually be (re-)drawn.
setBoundsSets the bounds on this instance
moveToReposition the tile.
clearClear the tile of any bounds/position-related data so that it can be reused in a new location.

Properties

events

{ALKMaps.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

beforedrawTriggered before the tile is drawn.  Used to defer drawing to an animation queue.  To defer drawing, listeners need to return false, which will abort drawing.  The queue handler needs to call <draw>(true) to actually draw the tile.
loadstartTriggered when tile loading starts.
loadendTriggered when tile loading ends.
loaderrorTriggered before the loadend event (i.e. when the tile is still hidden) if the tile could not be loaded.
reloadTriggered when an already loading tile is reloaded.
unloadTriggered before a tile is unloaded.

eventListeners

{Object} If set as an option at construction, the eventListeners object will be registered with ALKMaps.Events.on.  Object structure must be a listeners object as shown in the example for the events.on method.

This options can be set in the ``tileOptions`` option from ALKMaps.Layer.Grid.  For example, to be notified of the ``loadend`` event of each tiles:

new ALKMaps.Layer.OSM('osm', 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', {
    tileOptions: {
        eventListeners: {
            'loadend': function(evt) {
                // do something on loadend
            }
        }
    }
});

id

{String} null

layer

{ALKMaps.Layer} layer the tile is attached to

url

{String} url of the request.

TBD 3.0 Deprecated.  The base tile class does not need an url.  This should be handled in subclasses.  Does not belong here.

bounds

size

position

{ALKMaps.Pixel} Top Left pixel of the tile

isLoading

{Boolean} Is the tile loading?

Constructor

ALKMaps.Tile

Constructor for a new ALKMaps.Tile instance.

Parameters

layer{ALKMaps.Layer} layer that the tile will go in.
position{ALKMaps.Pixel}
bounds{ALKMaps.Bounds}
url{String}
size{ALKMaps.Size}
options{Object}

Functions

unload

unload: function()

Call immediately before destroying if you are listening to tile events, so that counters are properly handled if tile is still loading at destroy-time.  Will only fire an event if the tile is still loading.

destroy

destroy:function()

Nullify references to prevent circular references and memory leaks.

draw

draw: function(deferred)

Clear whatever is currently in the tile, then return whether or not it should actually be re-drawn.  This is an example implementation that can be overridden by subclasses.  The minimum thing to do here is to call clear and return the result from shouldDraw.

Parameters

deferred{Boolean} When drawing was aborted by returning false from a beforedraw listener, the queue manager needs to pass true, so the tile will not be cleared and immediately be drawn.  Otherwise, the tile will be cleared and a beforedraw event will be fired.

Returns

{Boolean} Whether or not the tile should actually be drawn.

shouldDraw

shouldDraw: function()

Return whether or not the tile should actually be (re-)drawn.  The only case where we wouldn’t want to draw the tile is if the tile is outside its layer’s maxExtent

Returns

{Boolean} Whether or not the tile should actually be drawn.

setBounds

setBounds: function(bounds)

Sets the bounds on this instance

Parameters

bounds {ALKMaps.Bounds}

moveTo

moveTo: function (bounds,
position,
redraw)

Reposition the tile.

Parameters

bounds{ALKMaps.Bounds}
position{ALKMaps.Pixel}
redraw{Boolean} Call draw method on tile after moving.  Default is true

clear

clear: function(draw)

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

on: function(object)
Convenience method for registering listeners with a common scope.
Instances of this class represent bounding boxes.
Instances of this class represent a width/height pair
This class represents a screen coordinate, in x and y coordinates
Constructor for a new ALKMaps.Tile instance.
unload: function()
Call immediately before destroying if you are listening to tile events, so that counters are properly handled if tile is still loading at destroy-time.
destroy:function()
Nullify references to prevent circular references and memory leaks.
draw: function(deferred)
Clear whatever is currently in the tile, then return whether or not it should actually be re-drawn.
shouldDraw: function()
Return whether or not the tile should actually be (re-)drawn.
setBounds: function(bounds)
Sets the bounds on this instance
moveTo: function (bounds,
position,
redraw)
Reposition the tile.
clear: function(draw)
Clear the tile of any bounds/position-related data so that it can be reused in a new location.
Base class for layers that use a lattice of tiles.
Contains convenience functions for string manipulation.
Close