Legacy
Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.
You are viewing an older version of Mapbox.js. Check out v3.3.1 for the latest.
TileLayer.Canvas
Used to create Canvas-based tile layers where tiles get drawn on the browser side. Extends TileLayer.
Usage example
var canvasTiles = L.tileLayer.canvas();
canvasTiles.drawTile = function(canvas, tilePoint, zoom) {
var ctx = canvas.getContext('2d');
// draw something on the tile canvas
}
Creation
Factory | Description |
---|---|
L.tileLayer.canvas(
|
Instantiates a Canvas tile layer object given an options object (optionally). |
Options
Option | Type | Default | Description |
---|---|---|---|
async |
Boolean |
false |
Indicates that tiles will be drawn asynchronously. tileDrawn method should be called for each tile after drawing completion. |
Methods
Method | Returns | Description |
---|---|---|
drawTile(
|
this |
You need to define this method after creating the instance to draw tiles; canvas is the actual canvas tile on which you can draw, tilePoint represents the tile numbers, and zoom is the current zoom. |
tileDrawn( |
- | If async option is defined, this function should be called for each tile after drawing completion. canvas is the same canvas element, that was passed to drawTile. |