UNPKG

@deck.gl/experimental-layers

Version:

Experimental layers for deck.gl

87 lines (74 loc) 2.39 kB
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var Tile = /*#__PURE__*/ function () { function Tile(_ref) { var getTileData = _ref.getTileData, x = _ref.x, y = _ref.y, z = _ref.z, onGetTileDataError = _ref.onGetTileDataError; _classCallCheck(this, Tile); this.x = x; this.y = y; this.z = z; this.isVisible = true; this.getTileData = getTileData; this._data = null; this._isLoaded = false; this._loader = this._loadData(); this.onGetTileDataError = onGetTileDataError; } _createClass(Tile, [{ key: "_loadData", value: function _loadData() { var _this = this; var x = this.x, y = this.y, z = this.z; if (!this.getTileData) { return null; } var getTileDataPromise = this.getTileData({ x: x, y: y, z: z }); return getTileDataPromise.then(function (buffers) { _this._data = buffers; _this._isLoaded = true; return buffers; }).catch(function (err) { _this._isLoaded = true; _this.onGetTileDataError(err); }); } }, { key: "isOverlapped", value: function isOverlapped(tile) { var x = this.x, y = this.y, z = this.z; var m = Math.pow(2, tile.z - z); return Math.floor(tile.x / m) === x && Math.floor(tile.y / m) === y; } }, { key: "data", get: function get() { if (this._data) { return Promise.resolve(this._data); } return this._loader; } }, { key: "isLoaded", get: function get() { return this._isLoaded; } }]); return Tile; }(); export { Tile as default }; //# sourceMappingURL=tile.js.map