Select to view content in your preferred language

How can I get the MinScale and MaxScale from a tile package (.tpk)?

1579
3
06-30-2017 03:14 PM
StefanOrehovec
Emerging Contributor

When I create an ArcGISLocalTiledLayer and point it at the path to a tile package (.tpk) the MinScale and MaxScale properties are by default set to NaN.  

Here's why that is a problem, if the layer is the first one added to the map the map uses the MinScale and MaxScale of the tiles in that layer to restrict zooming of the map from then on.  If I then replace that tile package layer with another one with a different set of tiles at different scales the map will not zoom to them.  If I could find out what the MinScale and MaxScale of the tile package was I'd be able to change the map MinScale and MaxScale when the new layer was loaded.  

The values are in the tile package in the mapservice.json file but I haven't found a way to read those values using the .Net SDK.

Tags (1)
0 Kudos
3 Replies
NagmaYasmin
Esri Contributor

Hi Stefan,

To get the scales of the different levels of a tile package you could use Tilecache class. Below is the code that gives you the scale for each level:

TileCache tileCache = new TileCache(<location_of_tpk_file>);
await tileCache.LoadAsync();

if(tileCache.LoadStatus == LoadStatus.Loaded)
     Console.WriteLine(tileCache.TileInfo.LevelsOfDetail);

var lods = tileCache.TileInfo.LevelsOfDetail.ToList();
foreach(LevelOfDetail lod in lods)
{
        Console.WriteLine("LOD Scale: " + lod.Scale);
        Console.WriteLine("LOD Level: " + lod.Level);
}

The scale exactly matches with the mapserver.json file of the tpk.

Attached is the output of my tpk. Hope that helps

TileCache Constructor LevelOfDetails of TileCache or TPK file

Nagma

0 Kudos
StefanOrehovec
Emerging Contributor

Nagma, 

Thank you for responding so quickly, this looks very promising.  Unfortunately I'm using version 10.2.7 of the SDK and this class doesn't exist.  Do you know if this functionality to read the LOD's from a .tpk exists in 10.2.7? 
 

Thank you,

Stefan

0 Kudos
NagmaYasmin
Esri Contributor

Hi Stefan,

I don't think it is possible with 10.2.7. There is no other class to determine the LODs of the local tiled package.

Nagma

0 Kudos