AnsweredAssumed Answered

Adding TileCache (TiledLayer) into MapView throws "No Data" error

Question asked by DaxtonH47 on Aug 23, 2018
Latest reply on Aug 24, 2018 by GDeStigter-esristaff

We have a Xamarin.Forms app that allows users to specify a basemap and offline-capable feature layers. The basemap and layers are then taken offline. The basemaps that we are allowing our users to pick from are the Esri created basemaps "For Export". Found here - http://www.arcgis.com/home/search.html?q=for%20export&t=content&focus=layers&start=1&sortOrder=desc&sortField=relevance 

 

So the problem: We have the ExportTileCacheTask being created based on which basemap the user chooses. The job then creates the .tpk file and stores it on the device. The problem is when the user navigates to the page where the MapView and the Map are created. The .tpk gets loaded into a Basemap layer from the device, but always throws a "No Data" error. This is happening specifically with the Topographic and Streets basemaps, but we have it working with the Imagery basemap. We can't identify any differences between these basemaps, and the code always runs the same regardless of which basemap is chosen. Here is some of our code:

 

var portalItem = await PortalItem.CreateAsync(new Uri(BASEMAP_BASEURL + mapConfig.SelectedBasemap.ID));


//Imagery Url = https://www.arcgis.com/home/item.html?id=226d23f076da478bba4589e7eae95952
//Topo Url = https://www.arcgis.com/home/item.html?id=df541726b3df4c0caf99255bb1be4c86


var task = await ExportTileCacheTask.CreateAsync(portalItem.ServiceUrl, cred);
var areaOfInterest = currentView;
var minScale = task.ServiceInfo.MinScale;
var maxScale = task.ServiceInfo.MaxScale;

 

var parameters = await task.CreateDefaultExportTileCacheParametersAsync(areaOfInterest, minScale, maxScale);


var path = AppSettings.TPKFilePath;

 

var job = task.ExportTileCache(parameters, path);
var tileCache = await job.GetResultAsync();


Note that the job.Status always returns a JobStatus.Succeeded. We immediately check the resulting tileCache, and it results in a "No Data" error.
Pulling .tpk out and into the MapView:

 

TileCache tileCache = new TileCache(AppSettings.TPKFilePath);

 

try
{
   await tileCache.LoadAsync();
}
catch (Exception)
{
   Debug.WriteLine(tileCache.LoadError);
    //Always states "No Data"
}
ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tileCache);
myMapView.Map.Basemap = new Basemap(tiledLayer);

 

If we remove the Try/Catch and don't .LoadAsync() the tileCache, the MapView becomes empty. Even the other operational layers we add after the basemap become empty. Whereas the Imagery basemap loads just fine. So the question is: why won't other basemaps work the same way? Thanks for any help in advance!

Outcomes