Select to view content in your preferred language

How to add several .tpk files while inizializing ArcGISTiledlayer?

1133
4
Jump to solution
10-19-2020 12:25 PM
VanyaIvanov
Regular Contributor

I want to create basemap using several map .tpk file.  

Basemap creation with one .tpk file works fine:


ArcGISTiledLayer tiledBasemapLayer = new ArcGISTiledLayer(new TileCache("C:\\Users\\user\\Documents\\ArcGIS\\01102020\\map1.tpk");
await tiledBasemapLayer.LoadAsync();
Scene newScene = new Scene();
newScene.Basemap = new Basemap(tiledBasemapLayer);

Scene = newScene;

The question is how to make this with two or more .tpk files?

ArcGISTiledLayer tiledBasemapLayer = new ArcGISTiledLayer(new TileCache("C:\\Users\\user\\Documents\\ArcGIS\\01102020\\map1.tpk", "C:\\Users\\osipa\\Documents\\ArcGIS\\011020200\\map2.tpk") ;        -------error "tileCache doesn't contain constructor that takes 2 arguments."

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

Almost there.

Instead of creating one ArcGISTiledLayer pointing at 2 TPKs, create 2 separate ArcGISTiledLayers, each pointing to one TPK, and add both of those layers to the new Basemap.

View solution in original post

4 Replies
Nicholas-Furness
Esri Regular Contributor

Almost there.

Instead of creating one ArcGISTiledLayer pointing at 2 TPKs, create 2 separate ArcGISTiledLayers, each pointing to one TPK, and add both of those layers to the new Basemap.

VanyaIvanov
Regular Contributor

Here is my soution. if somebody is interested in:

ArcGISTiledLayer tiledBasemapLayer1 = new ArcGISTiledLayer(new TileCache("C:\\Users\\user\\Documents\\ArcGIS\\01102020\\map1.tpk");
await tiledBasemapLayer1.LoadAsync();

ArcGISTiledLayer tiledBasemapLayer2 = new ArcGISTiledLayer(new TileCache("C:\\Users\\user\\Documents\\ArcGIS\\01102020\\map2.tpk");
await tiledBasemapLayer2.LoadAsync();

Scene newScene = new Scene();
newScene.Basemap = new Basemap(new ArcGISTiledLayer[] { tiledBasemapLayer1, tiledBasemapLayer2 });

Scene = newScene;

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Note, you don't need to explicitly call LoadAsync() on the layers. The way Runtime handles cascading dependencies will ensure that when the Scene is displayed in a SceneView, the SceneView will internally load the Scene, which will internally load the Basemap, which will internally load the two AGSTiledLayers.

You typically only need to explicitly load a Loadable object if you need to read properties from it.

MichaelBranscomb
Esri Frequent Contributor

...but we do recommend you handle the Loaded event to check there were no errors in loading: ILoadable.Loaded Event