OpenLayers.Control.UTFGrid

This Control provides behavior associated with UTFGrid Layers.  These ‘hit grids’ provide underlying feature attributes without calling the server (again).  This control allows Mousemove, Hovering and Click events to trigger callbacks that use the attributes in whatever way you need.

The most common example may be a UTFGrid layer containing feature attributes that are displayed in a div as you mouseover.

Example Code

var world_utfgrid = new OpenLayers.Layer.UTFGrid(
    'UTFGrid Layer',
    "http://tiles/world_utfgrid/${z}/${x}/${y}.json"
);
map.addLayer(world_utfgrid);

var control = new OpenLayers.Control.UTFGrid({
    layers: [world_utfgrid],
    handlerMode: 'move',
    callback: function(infoLookup) {
        // do something with returned data

    }
})

Inherits from

Summary
OpenLayers.Control.UTFGridThis Control provides behavior associated with UTFGrid Layers.
Properties
autoActivate{Boolean} Activate the control when it is added to a map.
LayersList of layers to consider.
defaultHandlerOptionsThe default opts passed to the handler constructors
handlerModeDefaults to ‘click’.
Functions
setHandlersets this.handlerMode and calls resetHandler()
resetHandlerDeactivates the old hanlder and creates a new OpenLayers.Handler based on the mode specified in this.handlerMode
Constructor
<OpenLayers.Control.UTFGrid>
Functions
handleEventInternal method called when specified event is triggered.
callbackFunction to be called when a mouse event corresponds with a location that includes data in one of the configured UTFGrid layers.
resetCalls the callback with null.
findLayersInternal method to get the layers, independent of whether we are inspecting the map or using a client-provided array

Properties

autoActivate

{Boolean} Activate the control when it is added to a map.  Default is true.

Layers

List of layers to consider.  Must be Layer.UTFGrids `null` is the default indicating all UTFGrid Layers are queried.  {Array} OpenLayers.Layer.UTFGrid

defaultHandlerOptions

The default opts passed to the handler constructors

handlerMode

Defaults to ‘click’.  Can be ‘hover’ or ‘move’.

Functions

setHandler

setHandler: function(hm)

sets this.handlerMode and calls resetHandler()

Parameters

hm{String} Handler Mode string; ‘click’, ‘hover’ or ‘move’.

resetHandler

resetHandler: function()

Deactivates the old hanlder and creates a new OpenLayers.Handler based on the mode specified in this.handlerMode

Constructor

<OpenLayers.Control.UTFGrid>

Parameters

options{Object}

Functions

handleEvent

handleEvent: function(evt)

Internal method called when specified event is triggered.

This method does several things

Gets the lonLat of the event.

Loops through the appropriate hit grid layers and gathers the attributes.

Passes the attributes to the callback

Parameters

evt{OpenLayers.Event}

callback

callback: function(infoLookup)

Function to be called when a mouse event corresponds with a location that includes data in one of the configured UTFGrid layers.

Parameters

infoLookup{Object} Keys of this object are layer indexes and can be used to resolve a layer in the map.layers array.  The structure of the property values depend on the data included in the underlying UTFGrid and may be any valid JSON type.

reset

reset: function(evt)

Calls the callback with null.

findLayers

findLayers: function()

Internal method to get the layers, independent of whether we are inspecting the map or using a client-provided array

The default value of this.layers is null; this causes the findLayers method to return ALL UTFGrid layers encountered.

Parameters

None

Returns

{Array} Layers to handle on each event

setHandler: function(hm)
sets this.handlerMode and calls resetHandler()
resetHandler: function()
Deactivates the old hanlder and creates a new OpenLayers.Handler based on the mode specified in this.handlerMode
Base class to construct a higher-level handler for event sequences.
handleEvent: function(evt)
Internal method called when specified event is triggered.
callback: function(infoLookup)
Function to be called when a mouse event corresponds with a location that includes data in one of the configured UTFGrid layers.
reset: function(evt)
Calls the callback with null.
findLayers: function()
Internal method to get the layers, independent of whether we are inspecting the map or using a client-provided array
Controls affect the display or behavior of the map.
This Layer reads from UTFGrid tiled data sources.
Utility functions for event handling.
Close