From 485c1987f08001bed5ec5c64b4e445504c903384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Tue, 11 Aug 2015 10:04:21 +0200 Subject: [PATCH] Document createTile async mode --- reference.html | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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; } });