当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Util.bind方法代码示例

本文整理汇总了TypeScript中leaflet.Util.bind方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Util.bind方法的具体用法?TypeScript Util.bind怎么用?TypeScript Util.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在leaflet.Util的用法示例。


在下文中一共展示了Util.bind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: return

		return (_err: any, data: any) => {
			if (data) {
				this.fire('tilecachehit', {
					tile,
					url: tileUrl
				});
				if (Date.now() > data.timestamp + this.options.cacheMaxAge && !this.options.useOnlyCache) {
					// Tile is too old, try to refresh it
					console.log('Tile is too old: ', tileUrl);

					if (this.options.saveToCache) {
						tile.onload = L.Util.bind((this._saveTile as any), this, tile, tileUrl, false, done);
					}
					tile.crossOrigin = 'Anonymous';
					tile.src = tileUrl;
					tile.onerror = function(_ev: any) {
						// If the tile is too old but couldn't be fetched from the network,
						//   serve the one still in cache.
						(this as HTMLImageElement).src = data.dataUrl;
					};
				} else {
					// Serve tile from cached data
					// console.log('Tile is cached: ', tileUrl);
					tile.onload = L.Util.bind((this._tileOnLoad as any), this, done, tile);
					tile.src = data.dataUrl;    // data.dataUrl is already a base64-encoded PNG image.
				}
			} else {
				this.fire('tilecachemiss', {
					tile,
					url: tileUrl
				});
				if (this.options.useOnlyCache) {
					// Offline, not cached
					// console.log('Tile not in cache', tileUrl);
					tile.onload = L.Util.falseFn;
					tile.src = L.Util.emptyImageUrl;
				} else {
					//Online, not cached, request the tile normally
					// console.log('Requesting tile normally', tileUrl);
					if (this.options.saveToCache) {
						tile.onload = L.Util.bind((this._saveTile as any), this, tile, tileUrl, null, done);
					} else {
						tile.onload = L.Util.bind((this._tileOnLoad as any), this, done, tile);
					}
					tile.crossOrigin = 'Anonymous';
					tile.src = tileUrl;
				}
			}
		};
开发者ID:hagai26,项目名称:Leaflet.TileLayer.PouchDBCached,代码行数:49,代码来源:leaflet-cached-tilelayer.ts

示例2:

};

const obj5 = {
	prop5: 'cinque',
};

const extended0: typeof obj1 = L.Util.extend(obj1);
const extended1: typeof obj1 & typeof obj2 = L.Util.extend(obj1, obj2);
const extended2: typeof obj1 & typeof obj2 & typeof obj3 = L.Util.extend(obj1, obj2, obj3);
const extended3: typeof obj1 & typeof obj2 & typeof obj3 & typeof obj4 = L.Util.extend(obj1, obj2, obj3, obj4);
const extended4: typeof obj1 & typeof obj2 & typeof obj3 & typeof obj4 & typeof obj5 = L.Util.extend(obj1, obj2, obj3, obj4, obj5);

L.Util.create({});
L.Util.create(null, {foo: {writable: true, value: 'bar'}});

L.Util.bind(() => {}, {});
L.Util.stamp({});
L.Util.throttle(() => {}, 123, {});
L.Util.wrapNum(123, []);
L.Util.wrapNum(123, [], true);
L.Util.falseFn();
L.Util.formatNum(123);
L.Util.formatNum(123, 1);
L.Util.trim('word   ');
L.Util.splitWords('word word');
L.Util.setOptions({}, {});
L.Util.getParamString({});
L.Util.getParamString({}, '');
L.Util.getParamString({}, '', true);
L.Util.template('template', {});
L.Util.isArray({});
开发者ID:Igorbek,项目名称:DefinitelyTyped,代码行数:31,代码来源:leaflet-tests.ts

示例3: createTile

// 🍂option cacheMaxAge: Number = 24 * 3600 * 1000
// Maximum age of the cache, in milliseconds
L.TileLayer.prototype.options.cacheMaxAge  = 24 * 3600 * 1000;

// Size limit for the DB in MB, (assuming a 12 Ko weight for a single tile)
L.TileLayer.prototype.options.dbSizeLimit  = 40; // in Mb


L.TileLayer.include({

	// Overwrites L.TileLayer.prototype.createTile
	createTile(this: CachedTileLayer, coords: TileCoords, done: () => void) {
		const tile = document.createElement('img');

		tile.onerror = L.Util.bind((this._tileOnError as any), this, done, tile);

		if (this.options.crossOrigin) {
			tile.crossOrigin = '';
		}

		/*
			Alt tag is *set to empty string to keep screen readers from reading URL and for compliance reasons
			http://www.w3.org/TR/WCAG20-TECHS/H67
			*/
		tile.alt = '';

		const tileUrl = this.getTileUrl(coords);

		if (this.options.useCache && this._canvas) {
			// TODO - can I remove: revs_info: true here?
开发者ID:hagai26,项目名称:Leaflet.TileLayer.PouchDBCached,代码行数:30,代码来源:leaflet-cached-tilelayer.ts


注:本文中的leaflet.Util.bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。