UNPKG

@nativescript-community/ui-carto

Version:
75 lines 3.03 kB
import { TileDataSource } from '.'; import { toNativeMapBounds } from '../core'; import { nativeProperty } from '..'; export class PersistentCacheTileDataSource extends TileDataSource { createNative(options) { if (options.databasePath) { return new com.carto.datasources.PersistentCacheTileDataSource(options.dataSource.getNative(), options.databasePath); } else { return new com.carto.datasources.PersistentCacheTileDataSource(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 = new com.akylas.carto.additions.AKTileDownloadListener(new com.akylas.carto.additions.AKTileDownloadListener.Listener({ onDownloadCompleted() { if (tileDownloadListener && tileDownloadListener.onDownloadCompleted) { tileDownloadListener.onDownloadCompleted(); } resolve(); loaderListener = null; }, onDownloadFailed(tile) { if (tileDownloadListener && tileDownloadListener.onDownloadFailed) { tileDownloadListener.onDownloadFailed({ tileId: tile.getTileId(), x: tile.getX(), y: tile.getY() }); } }, onDownloadProgress(progress) { if (tileDownloadListener && tileDownloadListener.onDownloadProgress) { tileDownloadListener.onDownloadProgress(progress); } }, onDownloadStarting(tileCount) { if (tileDownloadListener && tileDownloadListener.onDownloadStarting) { tileDownloadListener.onDownloadStarting(tileCount); } } })); this.getNative().startDownloadArea(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 new com.carto.datasources.MemoryCacheTileDataSource(options.dataSource.getNative()); } } __decorate([ nativeProperty ], MemoryCacheTileDataSource.prototype, "capacity", void 0); //# sourceMappingURL=cache.android.js.map