Using multiple TPK files on one mapview (.Net Runtime)

6032
7
01-28-2015 03:23 AM
JaredWheatley
New Contributor

Hi All,

We have been provided multiple .tpk basemaps for different sections of the map, as its very large and we are attempting to use tablets, meaning only relevant sections of the map will be loaded onto the tablet.

So each "region" of the map has been given to us in a .tpk file. This works fine when adding just one section of the map onto the mapview, I'm wondering if adding the second section as a different ArcGISLocalTiledLayer will work, such as this?:

var MapSection1 = new ArcGISLocalTiledLayer(@"ms-appx:///Assets/OSBasemapPackage.tpk");

var MapSection2 = new ArcGISLocalTiledLayer(@"ms-appx:///Assets/OSBasemapPkgEastCentral.tpk");

           

MapSection1.ID = "mp1";

MapSection2.ID = "mp2";

MyMap.Layers.Add(MapSection1);

MyMap.Layers.Add(MapSection2);

0 Kudos
7 Replies
AnttiKajanus1
Occasional Contributor III

Should work. If you get any issues, please let us know.

0 Kudos
JaredWheatley
New Contributor

Thank you, will do

0 Kudos
Riyasdsrc
New Contributor II

Hi Team,

We are developing a Xamarin Mobile app that uses arcGIS maps. We are also facing the same situation as mentioned above

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

0 Kudos
ShaharBukra
New Contributor III

it will work, the only think you need to be sure of is that the WKID is the same on both tpks...

otherwise it will not work

0 Kudos
JaredWheatley
New Contributor

Hi, What exactly is a WKID? we haven't been packaging them into TPK's.

Thanks

0 Kudos
ShaharBukra
New Contributor III

The spatial reference of the tpks (WKID = well known id)

maybe you will be able to understand with the JS doc

https://developers.arcgis.com/javascript/jsapi/spatialreference-amd.html

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

Hopefully the Spatial Reference doc in the .NET SDK Guide will help: Spatial references—ArcGIS Runtime SDK for .NET | ArcGIS for Developers

If not please let us know!

Cheers

0 Kudos