Using multiple TPK files on one Mapview arcgis

708
0
12-23-2020 10:16 PM
Riyasdsrc
New Contributor II

Hi Team,

We are developing a Xamarin Mobile app that uses arcGIS maps. 

We have 3 tpk files has different zoom level with whole area and another 6 tpk files with areas splitted into 6 small areas from the whole area. We tried to add these tpk files in the map layers as ArcGISTileLayer from TileCache.

But all the time only the first tpk layer is loaded. Currently using arcGIS .net runtime Xamarin Forms nuget version 100.8.0

Any help would be much appreciated 

Please refer the code below

string[] test = new string[] { "layer1.tpk", "layer2.tpk", "layer3.tpk" , "layer141.tpk", "layer142.tpk", "layer143.tpk", "layer144.tpk", "layer145.tpk", "layer146.tpk" };

Basemap sfBasemap = null;

foreach (var item in test)
{
string tileCachePath = string.Empty;

if (Device.RuntimePlatform == Device.UWP)
tileCachePath = localFileProvider.GetLocalFilePaths(item).Result;
else
tileCachePath = localFileProvider.GetLocalFilePath(item);

TileCache tileCache = new TileCache(tileCachePath);

// Create the corresponding layer based on the tile cache.
ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache);
tileLayer.Id = tileLayer.Name;
try
{
tileLayer.LoadStatusChanged += (s, e) =>
{
switch (e.Status)
{
case Esri.ArcGISRuntime.LoadStatus.Loaded:
tileLayers.Add(tileLayer);
break;
case Esri.ArcGISRuntime.LoadStatus.Loading:
break;
case Esri.ArcGISRuntime.LoadStatus.FailedToLoad:
break;
case Esri.ArcGISRuntime.LoadStatus.NotLoaded:
break;
default:
break;
}
};
}
catch (Exception)
{
continue;
}

await tileLayer.LoadAsync();
}


// Create the map with the tile-based basemap.
Map myMap = new Map(new Basmap(tileLayers));
// Assign the map to the MapView.
myMapView.Map = myMap;

await myMapView.Map.LoadAsync();

 

Thanks

Tags (4)
0 Replies