Sha256: 685a3f18c27c202d7931be5e3b13a84a53991ad98fca61a7b16e132364b8568e

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

/*
 * L.TileLayer.Canvas is a class that you can use as a base for creating
 * dynamically drawn Canvas-based tile layers.
 */

L.TileLayer.Canvas = L.TileLayer.extend({
	options: {
		async: false
	},

	initialize: function (options) {
		L.setOptions(this, options);
	},

	redraw: function () {
		if (this._map) {
			this._reset({hard: true});
			this._update();
		}

		for (var i in this._tiles) {
			this._redrawTile(this._tiles[i]);
		}
		return this;
	},

	_redrawTile: function (tile) {
		this.drawTile(tile, tile._tilePoint, this._map._zoom);
	},

	_createTile: function () {
		var tile = L.DomUtil.create('canvas', 'leaflet-tile');
		tile.width = tile.height = this.options.tileSize;
		tile.onselectstart = tile.onmousemove = L.Util.falseFn;
		return tile;
	},

	_loadTile: function (tile, tilePoint) {
		tile._layer = this;
		tile._tilePoint = tilePoint;

		this._redrawTile(tile);

		if (!this.options.async) {
			this.tileDrawn(tile);
		}
	},

	drawTile: function (/*tile, tilePoint*/) {
		// override with rendering code
	},

	tileDrawn: function (tile) {
		this._tileOnLoad.call(tile);
	}
});


L.tileLayer.canvas = function (options) {
	return new L.TileLayer.Canvas(options);
};

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
leaflet-js-0.7.9 vendor/assets/Leaflet/src/layer/tile/TileLayer.Canvas.js
leaflet-js-0.7.8 vendor/assets/Leaflet/src/layer/tile/TileLayer.Canvas.js
leaflet-js-0.7.7 vendor/assets/Leaflet/src/layer/tile/TileLayer.Canvas.js
leaflet-js-0.7.0.4 lib/leaflet/src/layer/tile/TileLayer.Canvas.js
leaflet-js-0.7.0.3 lib/leaflet/src/layer/tile/TileLayer.Canvas.js
leaflet-js-0.7.0.2 lib/leaflet/src/layer/tile/TileLayer.Canvas.js
leaflet-js-0.7.0.1 lib/leaflet/src/layer/tile/TileLayer.Canvas.js
leaflet-js-0.7.0 lib/leaflet/src/layer/tile/TileLayer.Canvas.js