lib/leaflet.js
function (center) {
		var map = this._map;
		if (!map) { return; }
		var zoom = map.getZoom();

		if (center === undefined) { center = map.getCenter(); }
		if (this._tileZoom === undefined) { return; }	// if out of minzoom/maxzoom

		var pixelBounds = this._getTiledPixelBounds(center),
		    tileRange = this._pxBoundsToTileRange(pixelBounds),
		    tileCenter = tileRange.getCenter(),
		    queue = [],
		    margin = this.options.keepBuffer,
		    noPruneRange = new L.Bounds(tileRange.getBottomLeft().subtract([margin, -margin]),
		                              tileRange.getTopRight().add([margin, -margin]));

		for (var key in this._tiles) {
			var c = this._tiles[key].coords;
			if (c.z !== this._tileZoom || !noPruneRange.contains(L.point(c.x, c.y))) {
				this._tiles[key].current = false;
			}
		}

		// _update just loads more tiles. If the tile zoom level differs too much
		// from the map's, let _setView reset levels and prune old tiles.
		if (Math.abs(zoom - this._tileZoom) > 1) { this._setView(center, zoom); return; }

		// create a queue of coordinates to load tiles from
		for (var j = tileRange.min.y; j <= tileRange.max.y; j++) {
			for (var i = tileRange.min.x; i <= tileRange.max.x; i++) {
				var coords = new L.Point(i, j);
				coords.z = this._tileZoom;

				if (!this._isValidTile(coords)) { continue; }

				var tile = this._tiles[this._tileCoordsToKey(coords)];
				if (tile) {
					tile.current = true;
				} else {
					queue.push(coords);
				}
			}
		}

		// sort tile queue to load tiles in order of their distance to center
		queue.sort(function (a, b) {
			return a.distanceTo(tileCenter) - b.distanceTo(tileCenter);
		});

		if (queue.length !== 0) {
			// if its the first batch of tiles to load
			if (!this._loading) {
				this._loading = true;
				// @event loading: Event
				// Fired when the grid layer starts loading tiles.
				this.fire('loading');
			}

			// create DOM fragment to append tiles in one batch
			var fragment = document.createDocumentFragment();

			for (i = 0; i < queue.length; i++) {
				this._addTile(queue[i], fragment);
			}

			this._level.el.appendChild(fragment);
		}
	}
function (center) {
		var map = this._map;
		if (!map) { return; }
		var zoom = map.getZoom();

		if (center === undefined) { center = map.getCenter(); }
		if (this._tileZoom === undefined) { return; }	// if out of minzoom/maxzoom

		var pixelBounds = this._getTiledPixelBounds(center),
		    tileRange = this._pxBoundsToTileRange(pixelBounds),
		    tileCenter = tileRange.getCenter(),
		    queue = [],
		    margin = this.options.keepBuffer,
		    noPruneRange = new L.Bounds(tileRange.getBottomLeft().subtract([margin, -margin]),
		                              tileRange.getTopRight().add([margin, -margin]));

		for (var key in this._tiles) {
			var c = this._tiles[key].coords;
			if (c.z !== this._tileZoom || !noPruneRange.contains(L.point(c.x, c.y))) {
				this._tiles[key].current = false;
			}
		}

		// _update just loads more tiles. If the tile zoom level differs too much
		// from the map's, let _setView reset levels and prune old tiles.
		if (Math.abs(zoom - this._tileZoom) > 1) { this._setView(center, zoom); return; }

		// create a queue of coordinates to load tiles from
		for (var j = tileRange.min.y; j <= tileRange.max.y; j++) {
			for (var i = tileRange.min.x; i <= tileRange.max.x; i++) {
				var coords = new L.Point(i, j);
				coords.z = this._tileZoom;

				if (!this._isValidTile(coords)) { continue; }

				var tile = this._tiles[this._tileCoordsToKey(coords)];
				if (tile) {
					tile.current = true;
				} else {
					queue.push(coords);
				}
			}
		}

		// sort tile queue to load tiles in order of their distance to center
		queue.sort(function (a, b) {
			return a.distanceTo(tileCenter) - b.distanceTo(tileCenter);
		});

		if (queue.length !== 0) {
			// if its the first batch of tiles to load
			if (!this._loading) {
				this._loading = true;
				// @event loading: Event
				// Fired when the grid layer starts loading tiles.
				this.fire('loading');
			}

			// create DOM fragment to append tiles in one batch
			var fragment = document.createDocumentFragment();

			for (i = 0; i < queue.length; i++) {
				this._addTile(queue[i], fragment);
			}

			this._level.el.appendChild(fragment);
		}
	}
function ( center ) { var map = this . _map ; if ( ! map ) { return ; } var zoom = map . getZoom ( ) ; if ( center === undefined ) { center = map . getCenter ( ) ; } if ( this . _tileZoom === undefined ) { return ; } // if out of minzoom/maxzoom var pixelBounds = this . _getTiledPixelBounds ( center ) , tileRange = this . _pxBoundsToTileRange ( pixelBounds ) , tileCenter = tileRange . getCenter ( ) , queue = [ ] , margin = this . options . keepBuffer , noPruneRange = new L . Bounds ( tileRange . getBottomLeft ( ) . subtract ( [ margin , - margin ] ) , tileRange . getTopRight ( ) . add ( [ margin , - margin ] ) ) ; for ( var key in this . _tiles ) { var c = this . _tiles [ key ] . coords ; if ( c . z !== this . _tileZoom || ! noPruneRange . contains ( L . point ( c . x , c . y ) ) ) { this . _tiles [ key ] . current = false ; } } // _update just loads more tiles. If the tile zoom level differs too much // from the map's, let _setView reset levels and prune old tiles. if ( Math . abs ( zoom - this . _tileZoom ) > 1 ) { this . _setView ( center , zoom ) ; return ; } // create a queue of coordinates to load tiles from for ( var j = tileRange . min . y ; j <= tileRange . max . y ; j ++ ) { for ( var i = tileRange . min . x ; i <= tileRange . max . x ; i ++ ) { var coords = new L . Point ( i , j ) ; coords . z = this . _tileZoom ; if ( ! this . _isValidTile ( coords ) ) { continue ; } var tile = this . _tiles [ this . _tileCoordsToKey ( coords ) ] ; if ( tile ) { tile . current = true ; } else { queue . push ( coords ) ; } } } // sort tile queue to load tiles in order of their distance to center queue . sort ( function ( a , b ) { return a . distanceTo ( tileCenter ) - b . distanceTo ( tileCenter ) ; } ) ; if ( queue . length !== 0 ) { // if its the first batch of tiles to load if ( ! this . _loading ) { this . _loading = true ; // @event loading: Event // Fired when the grid layer starts loading tiles. this . fire ( 'loading' ) ; } // create DOM fragment to append tiles in one batch var fragment = document . createDocumentFragment ( ) ; for ( i = 0 ; i < queue . length ; i ++ ) { this . _addTile ( queue [ i ] , fragment ) ; } this . _level . el . appendChild ( fragment ) ; } }
Private method to load tiles in the grid's active zoom level according to map bounds
Private method to load tiles in the grid s active zoom level according to map bounds