gridLayer.on(event, handler, context)

Bind an event handler to a given event on this L.mapbox.gridLayer instance.
GridLayers expose a number of useful events that give you access to UTFGrid
data as the user interacts with the map.

Options

Value

Description

event (required)

string

the event name

handler (required)

function

a callback function run every time that the event is fired

context (optional)

object

the context of the handler function: this is the value of this when that function returns

After binding an event with .on, you can unbind it with .off, with the
same argument structure.

The default events are:

click: mouse has clicked while on a feature in UTFGrid. Event has { latLng: location, data: featureData } as its data.

mouseover: mouse has moved onto a new feature in UTFGrid. Event has { latLng: location, data: featureData } as its data.

mousemove: mouse has moved within a feature in UTFGrid. Event has { latLng: location, data: featureData } as its data.

mouseout: mouse has moved from a feature to an area without any features. Event has { latLng: location, data: featureData } as its data, in which featureData is the feature data the mouse was previously on.