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.
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 } })
OpenLayers. | This Control provides behavior associated with UTFGrid Layers. |
Properties | |
autoActivate | {Boolean} Activate the control when it is added to a map. |
Layers | List of layers to consider. |
defaultHandlerOptions | The default opts passed to the handler constructors |
handlerMode | Defaults to ‘click’. |
Functions | |
setHandler | sets this.handlerMode and calls resetHandler() |
resetHandler | Deactivates the old hanlder and creates a new OpenLayers.Handler based on the mode specified in this.handlerMode |
Constructor | |
<OpenLayers. | |
Functions | |
handleEvent | Internal method called when specified event is triggered. |
callback | Function to be called when a mouse event corresponds with a location that includes data in one of the configured UTFGrid layers. |
reset | Calls the callback with null. |
findLayers | Internal method to get the layers, independent of whether we are inspecting the map or using a client-provided array |
List of layers to consider. Must be Layer.UTFGrids `null` is the default indicating all UTFGrid Layers are queried. {Array} OpenLayers.Layer.UTFGrid
resetHandler: function()
Deactivates the old hanlder and creates a new OpenLayers.Handler based on the mode specified in this.handlerMode
handleEvent: function( evt )
Internal method called when specified event is triggered.
Gets the lonLat of the event.
Loops through the appropriate hit grid layers and gathers the attributes.
Passes the attributes to the callback
evt | {OpenLayers.Event} |
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.
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. |
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.
None
{Array} Layers to handle on each event
sets this.handlerMode and calls resetHandler()
setHandler: function( hm )
Deactivates the old hanlder and creates a new OpenLayers.Handler based on the mode specified in this.handlerMode
resetHandler: function()
Internal method called when specified event is triggered.
handleEvent: function( evt )
Function to be called when a mouse event corresponds with a location that includes data in one of the configured UTFGrid layers.
callback: function( infoLookup )
Calls the callback with null.
reset: function( evt )
Internal method to get the layers, independent of whether we are inspecting the map or using a client-provided array
findLayers: function()