OpenLayers.Tile.UTFGrid - OpenLayers

# OpenLayers.Tile.UTFGrid

Instances of OpenLayers.Tile.UTFGrid are used to manage UTFGrids. This is an unusual tile type in that it doesn’t have a rendered image; only a ‘hit grid’ that can be used to look up feature attributes.

See the OpenLayers.Tile.UTFGrid constructor for details on constructing a new instance.

#### Inherits from

- OpenLayers.Tile

Summary

OpenLayers.Tile.UTFGrid | Instances of OpenLayers.Tile.UTFGrid are used to manage UTFGrids.
Properties |
url | {String} The URL of the UTFGrid file being requested.
utfgridResolution | {Number} Ratio of the pixel width to the width of a UTFGrid data point.
json | {Object} Stores the parsed JSON tile data structure.
format | {OpenLayers.Format.JSON} Parser instance used to parse JSON for cross browser support.
Constructor |
OpenLayers.Tile.UTFGrid | Constructor for a new OpenLayers.Tile.UTFGrid instance.
Functions |
destroy | Clean up.
draw | Check that a tile should be drawn, and draw it.
abortLoading | Cancel a pending request.
getFeatureInfo | Get feature information associated with a pixel offset.
getFeatureId | Get the identifier for the feature associated with a pixel offset.
indexFromCharCode | Given a character code for one of the UTFGrid “grid” characters, resolve the integer index for the feature id in the UTFGrid “keys” array.
parseData | Parse the JSON from a request
clear | Delete data stored with this tile.

### Properties

### url

{String} The URL of the UTFGrid file being requested. Provided by the getURL method.

### utfgridResolution

{Number} Ratio of the pixel width to the width of a UTFGrid data point. If an entry in the grid represents a 4x4 block of pixels, the utfgridResolution would be 4. Default is 2.

### json

{Object} Stores the parsed JSON tile data structure.

### format

{OpenLayers.Format.JSON} Parser instance used to parse JSON for cross browser support. The native JSON.parse method will be used where available (all except IE<8).

### Constructor

### OpenLayers.Tile.UTFGrid

Constructor for a new OpenLayers.Tile.UTFGrid 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()

Clean up.

### draw

> draw: function()

Check that a tile should be drawn, and draw it. In the case of UTFGrids, “drawing” it means fetching and parsing the json.

#### Returns

{Boolean} Was a tile drawn?

### abortLoading

> abortLoading: function()

Cancel a pending request.

### getFeatureInfo

> getFeatureInfo: function( | i,
> | j | )

Get feature information associated with a pixel offset. If the pixel offset corresponds to a feature, the returned object will have id and data properties. Otherwise, null will be returned.

#### Parameters

i | {Number} X-axis pixel offset (from top left of tile)
j | {Number} Y-axis pixel offset (from top left of tile)

#### Returns

{Object} Object with feature id and data properties corresponding to the given pixel offset.

### getFeatureId

> getFeatureId: function( | i,
> | j | )

Get the identifier for the feature associated with a pixel offset.

#### Parameters

i | {Number} X-axis pixel offset (from top left of tile)
j | {Number} Y-axis pixel offset (from top left of tile)

#### Returns

{Object} The feature identifier corresponding to the given pixel offset. Returns null if pixel doesn’t correspond to a feature.

### indexFromCharCode

> indexFromCharCode: function( | charCode | )

Given a character code for one of the UTFGrid “grid” characters, resolve the integer index for the feature id in the UTFGrid “keys” array.

#### Parameters

charCode | {Integer}

#### Returns

{Integer} Index for the feature id from the keys array.

### parseData

> parseData: function( | str | )

Parse the JSON from a request

#### Parameters

str | {String} UTFGrid as a JSON string.

#### Returns

{Object} parsed javascript data

### clear

> clear: function()

Delete data stored with this tile.

Constructor for a new OpenLayers.Tile.UTFGrid instance.

> destroy: function()

Clean up.

> draw: function()

Check that a tile should be drawn, and draw it.

> abortLoading: function()

Cancel a pending request.

> getFeatureInfo: function( | i,
> | j | )

Get feature information associated with a pixel offset.

> getFeatureId: function( | i,
> | j | )

Get the identifier for the feature associated with a pixel offset.

> indexFromCharCode: function( | charCode | )

Given a character code for one of the UTFGrid “grid” characters, resolve the integer index for the feature id in the UTFGrid “keys” array.

> parseData: function( | str | )

Parse the JSON from a request

> clear: function()

Delete data stored with this tile.

> getURL: function ( | bounds | )

Determine the URL for a tile given the tile bounds.
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