leaflet#DoneCallback TypeScript Examples

The following examples show how to use leaflet#DoneCallback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LiveAtlasTileLayer.ts    From LiveAtlas with Apache License 2.0 6 votes vote down vote up
// @method createTile(coords: Object, done?: Function): HTMLElement
	// Called only internally, overrides GridLayer's [`createTile()`](#gridlayer-createtile)
	// to return an `<img>` HTML element with the appropriate image URL given `coords`. The `done`
	// callback is called when the tile has been loaded.
	createTile(coords: Coords, done: DoneCallback) {
		const tile = this.tileTemplate.cloneNode(false) as LiveAtlasTileElement;
		this.loadQueue.push(tile);

		tile.onload = () => {
			URL.revokeObjectURL(tile.src); //Revoke the object URL as we don't need it anymore

			this._tileOnLoad(done, tile);
			this.loadingTiles.delete(tile);
			this.tickLoadQueue();
		};

		tile.onerror = () => {
			this._tileOnError(done, tile, LiveAtlasTileLayer.genericLoadError);
			this.loadingTiles.delete(tile);
			this.tickLoadQueue();
		};

		tile.url = this.getTileUrl(coords);
		tile.callback = done;

		this.tickLoadQueue();

		return tile;
	}
Example #2
Source File: DynmapTileLayer.ts    From LiveAtlas with Apache License 2.0 5 votes vote down vote up
createTile(coords: Coords, done: DoneCallback) {
		const tile = super.createTile(coords, done);

		tile.tileName = this.getTileName(coords);
		this._namedTiles.set(tile.tileName, tile);

		return tile;
	}