diff --git a/reference.html b/reference.html index 12141d07..45d9b8fb 100644 --- a/reference.html +++ b/reference.html @@ -3373,9 +3373,10 @@ map.fitBounds(bounds);

Asyncronous usage example

-

Tile creation can also be asyncronous, this is useful when using a third-party drawing library. Once the tile is finsihed drawing it can be passed to the done() callback.

+

Tile creation can also be asyncronous, this is useful when using a third-party drawing library. Once the tile has finished drawing it must be passed to the done() callback.

var CanvasLayer = L.GridLayer.extend({
+	// createTile has a 'done' parameter when on async mode
 	createTile: function(coords, done){
 		var error;
 
@@ -3387,8 +3388,14 @@ map.fitBounds(bounds);
tile.width = size.x; tile.height = size.y; - // draw something and pass the tile to the done() callback - done(error, tile); + // For this example simply wait one second before tile is ready + window.setTimeout(function(){ + // draw something and pass the tile to the done() callback + done(error, tile); + }, 1000); + + // return the tile so its progress can be tracked + return tile; } });