diff --git a/src/ui-carto/utils/index.d.ts b/src/ui-carto/utils/index.d.ts index be98bce..d8545f4 100644 --- a/src/ui-carto/utils/index.d.ts +++ b/src/ui-carto/utils/index.d.ts @@ -14,6 +14,7 @@ export function setShowError(value: boolean); export interface ZippedAssetPackageOptions { zipPath: string; + basePack? } export class ZippedAssetPackage extends BaseNative { diff --git a/src/ui-carto/utils/index.ios.ts b/src/ui-carto/utils/index.ios.ts index 10a2cfe..517cd09 100644 --- a/src/ui-carto/utils/index.ios.ts +++ b/src/ui-carto/utils/index.ios.ts @@ -67,13 +67,27 @@ const currentAppFolder = knownFolders.currentApp(); export class ZippedAssetPackage extends BaseNative { createNative(options: ZippedAssetPackageOptions) { - const zipPath = getRelativePathToApp(options.zipPath); - if (File.exists(zipPath)) { - const vectorTileStyleSetData = NTAssetUtils.loadAsset(zipPath); - return NTZippedAssetPackage.alloc().initWithZipData(vectorTileStyleSetData); - } else { - console.error(`could not find zip file: ${options.zipPath}`); - return null; + let zipPath; + try { + const fullZipPath = getFileName(options.zipPath); + zipPath = getRelativePathToApp(options.zipPath); + if (File.exists(fullZipPath)) { + let assetPackage: NTAssetPackage; + if (options.basePack) { + assetPackage = options.basePack.getNative(); + } + const vectorTileStyleSetData = NTAssetUtils.loadAsset(zipPath); + if (assetPackage) { + return NTZippedAssetPackage.alloc().initWithZipDataBaseAssetPackage(vectorTileStyleSetData, assetPackage); + } else { + return NTZippedAssetPackage.alloc().initWithZipData(vectorTileStyleSetData); + } + } else { + throw new Error(`could not find zip file: ${options.zipPath}(${zipPath})`) + } + } catch (error) { + console.error(`ZippedAssetPackage(${zipPath}, ${options.zipPath}): ${error}`); + throw error; } } getAssetNames() {