--- layout: api title: "v1.6.1 API: L.mapbox.gridLayer(id|url|tilejson, options)" categories: api version: v1.6.1 permalink: /api/v1.6.1/l-mapbox-gridlayer --- {% raw %}
An L.mapbox.gridLayer
loads UTFGrid tiles of
interactivity into your map, which you can easily access with L.mapbox.gridControl
.
Options | Value | Description |
---|---|---|
id or url or tilejson (required) | string if id or url object if tilejson |
|
Example:
// the second argument is optional
var layer = L.mapbox.gridLayer('examples.map-20v6611k');
Returns a L.mapbox.gridLayer
object.
Returns this layer's TileJSON object which determines its tile source, zoom bounds and other metadata.
Example:
var layer = L.mapbox.gridLayer('examples.map-20v6611k')
// since layers load asynchronously through AJAX, use the
// `.on` function to listen for them to be loaded before
// calling `getTileJSON()`
.on('load', function() {
// get TileJSON data from the loaded layer
var TileJSON = layer.getTileJSON();
});
Returns: the TileJSON object
Load data for a given latitude, longitude point on the map, and call the callback function with that data, if any.
Options | Value | Description |
---|---|---|
latlng | object | latlng a L.LatLng object |
callback | function | callback a function that is called with the grid data as an argument |
Returns: the L.mapbox.gridLayer object
{% endraw %}