How to download part of a .tpk file in latest version of xamarin SDK 100.0.0.
In earlier version I have used this .NET Xamarin gist to download ArcGIS basemap tiles for offline use. · GitHub
it has worked fine but after updating the SDK getting build errors
Solved! Go to Solution.
Something like this
var overlay = MyMapView.GraphicsOverlays["areaOfInterestOverlay"];
if (overlay.Graphics.Count == 0) return;
var basemap = MyMapView.Map.Basemap.BaseLayers.OfType<ArcGISTiledLayer>().First();
var lods = basemap.ServiceInfo.TileInfo.LevelsOfDetail;
ExportTileCacheTask estimateTilesTask = null;
ExportTileCacheJob job = null;
try
{
estimateTilesTask = await ExportTileCacheTask.CreateAsync(basemap.Source, Authenticat ionManager.Current.Credentials.FirstOrDefault());
var parameters = await estimateTilesTask.CreateDefaultExportTileCacheParametersAsync( overlay.Graphics.First().Geometry.Extent, lods[0].Scale, lods[10].Scale);
job = estimateTilesTask.ExportTileCache(parameters, @"yourpathtothetpk.tpk");
var result = await job.GetResultAsync();
//await result.LoadAsync();
// Do something with loaded tile cache
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
foreach (var joMessage in job.Messages)
{
Debug.WriteLine(joMessage.Message);
}
Something like this
var overlay = MyMapView.GraphicsOverlays["areaOfInterestOverlay"];
if (overlay.Graphics.Count == 0) return;
var basemap = MyMapView.Map.Basemap.BaseLayers.OfType<ArcGISTiledLayer>().First();
var lods = basemap.ServiceInfo.TileInfo.LevelsOfDetail;
ExportTileCacheTask estimateTilesTask = null;
ExportTileCacheJob job = null;
try
{
estimateTilesTask = await ExportTileCacheTask.CreateAsync(basemap.Source, Authenticat ionManager.Current.Credentials.FirstOrDefault());
var parameters = await estimateTilesTask.CreateDefaultExportTileCacheParametersAsync( overlay.Graphics.First().Geometry.Extent, lods[0].Scale, lods[10].Scale);
job = estimateTilesTask.ExportTileCache(parameters, @"yourpathtothetpk.tpk");
var result = await job.GetResultAsync();
//await result.LoadAsync();
// Do something with loaded tile cache
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
foreach (var joMessage in job.Messages)
{
Debug.WriteLine(joMessage.Message);
}