L.TileLayer.PouchDBCached.js
function(tile, remaining, seedData) {
		if (!remaining.length) {
			this.fire("seedend", seedData);
			return;
		}
		this.fire("seedprogress", {
			bbox: seedData.bbox,
			minZoom: seedData.minZoom,
			maxZoom: seedData.maxZoom,
			queueLength: seedData.queueLength,
			remainingLength: remaining.length,
		});

		var url = remaining.shift();

		this._db.get(
			url,
			function(err, data) {
				if (!data) {
					/// FIXME: Do something on tile error!!
					tile.onload = function(ev) {
						this._saveTile(tile, url, null); //(ev)
						this._seedOneTile(tile, remaining, seedData);
					}.bind(this);
					tile.crossOrigin = "Anonymous";
					tile.src = url;
				} else {
					this._seedOneTile(tile, remaining, seedData);
				}
			}.bind(this)
		);
	}
function(tile, remaining, seedData) {
		if (!remaining.length) {
			this.fire("seedend", seedData);
			return;
		}
		this.fire("seedprogress", {
			bbox: seedData.bbox,
			minZoom: seedData.minZoom,
			maxZoom: seedData.maxZoom,
			queueLength: seedData.queueLength,
			remainingLength: remaining.length,
		});

		var url = remaining.shift();

		this._db.get(
			url,
			function(err, data) {
				if (!data) {
					/// FIXME: Do something on tile error!!
					tile.onload = function(ev) {
						this._saveTile(tile, url, null); //(ev)
						this._seedOneTile(tile, remaining, seedData);
					}.bind(this);
					tile.crossOrigin = "Anonymous";
					tile.src = url;
				} else {
					this._seedOneTile(tile, remaining, seedData);
				}
			}.bind(this)
		);
	}
function ( tile , remaining , seedData ) { if ( ! remaining . length ) { this . fire ( "seedend" , seedData ) ; return ; } this . fire ( "seedprogress" , { bbox : seedData . bbox , minZoom : seedData . minZoom , maxZoom : seedData . maxZoom , queueLength : seedData . queueLength , remainingLength : remaining . length , } ) ; var url = remaining . shift ( ) ; this . _db . get ( url , function ( err , data ) { if ( ! data ) { /// FIXME: Do something on tile error!! tile . onload = function ( ev ) { this . _saveTile ( tile , url , null ) ; //(ev) this . _seedOneTile ( tile , remaining , seedData ) ; } . bind ( this ) ; tile . crossOrigin = "Anonymous" ; tile . src = url ; } else { this . _seedOneTile ( tile , remaining , seedData ) ; } } . bind ( this ) ) ; }
Uses a defined tile to eat through one item in the queue and asynchronously recursively call itself when the tile has finished loading.
Uses a defined tile to eat through one item in the queue and asynchronously recursively call itself when the tile has finished loading .