UNPKG

@nativescript-community/ui-carto

Version:

NativeScript plugin for CARTO Mobile SDK

94 lines 3.6 kB
import { TileDataSource } from '.'; import { toNativeMapBounds } from '../core'; import { nativeProperty } from '..'; var NTTileDownloadListenerImpl = /** @class */ (function (_super) { __extends(NTTileDownloadListenerImpl, _super); function NTTileDownloadListenerImpl() { return _super !== null && _super.apply(this, arguments) || this; } NTTileDownloadListenerImpl.initWithOwner = function (owner, onComplete) { var delegate = NTTileDownloadListenerImpl.new(); delegate._owner = owner; delegate.mOnComplete = onComplete; return delegate; }; NTTileDownloadListenerImpl.prototype.onDownloadCompletedThreaded = function () { var _a; var owner = this._owner.get(); if (owner && owner.onDownloadCompleted) { owner.onDownloadCompleted(); } (_a = this.mOnComplete) === null || _a === void 0 ? void 0 : _a.call(this); }; NTTileDownloadListenerImpl.prototype.onDownloadFailedThreaded = function (tile) { var owner = this._owner.get(); if (owner && owner.onDownloadFailed) { owner.onDownloadFailed({ tileId: tile.getTileId(), x: tile.getX(), y: tile.getY() }); } }; NTTileDownloadListenerImpl.prototype.onDownloadProgressThreaded = function (progress) { var owner = this._owner.get(); if (owner && owner.onDownloadProgress) { owner.onDownloadProgress(progress); } }; NTTileDownloadListenerImpl.prototype.onDownloadStartingThreaded = function (tileCount) { var owner = this._owner.get(); if (owner && owner.onDownloadStarting) { owner.onDownloadStarting(tileCount); } }; return NTTileDownloadListenerImpl; }(AKTileDownloadListener)); export class PersistentCacheTileDataSource extends TileDataSource { createNative(options) { if (options.databasePath) { return NTPersistentCacheTileDataSource.alloc().initWithDataSourceDatabasePath(options.dataSource.getNative(), options.databasePath); } else { return NTPersistentCacheTileDataSource.alloc().initWithDataSource(options.dataSource.getNative()); } } close() { if (this.native) { this.native.close(); } } clear() { this.getNative().clear(); } isOpen() { return this.native && this.native.isOpen(); } stopAllDownloads() { return this.native && this.native.stopAllDownloads(); } startDownloadArea(mapBounds, minZoom, maxZoom, tileDownloadListener) { return new Promise((resolve, reject) => { let loaderListener = NTTileDownloadListenerImpl.initWithOwner(new WeakRef(tileDownloadListener), () => { resolve(); loaderListener = null; }); this.getNative().startDownloadAreaMinZoomMaxZoomTileDownloadListener(toNativeMapBounds(mapBounds), minZoom, maxZoom, loaderListener); }); } } __decorate([ nativeProperty ], PersistentCacheTileDataSource.prototype, "capacity", void 0); __decorate([ nativeProperty ], PersistentCacheTileDataSource.prototype, "cacheOnlyMode", void 0); export class MemoryCacheTileDataSource extends TileDataSource { createNative(options) { return NTMemoryCacheTileDataSource.alloc().initWithDataSource(options.dataSource.getNative()); } } __decorate([ nativeProperty ], MemoryCacheTileDataSource.prototype, "capacity", void 0); //# sourceMappingURL=cache.ios.js.map