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

990
3
Jump to solution
08-23-2018 02:49 PM
DaxtonHorspool
New Contributor

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&... 

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!

0 Kudos
1 Solution

Accepted Solutions
GregDeStigter
Esri Contributor

It looks like the Topo basemap you're referencing is a vector tile basemap. Those are different and have a different download task (`ExportVectorTilesTask`) and download a different format (.vtpk) which may or may not be what you want.

The export enabled image tiled version of the Topo basemap is here:

https://www.arcgis.com/home/item.html?id=eaee8760ed754019a964a6d785613a50

 if you want to give that a shot. That should work with the code you have.

View solution in original post

3 Replies
GregDeStigter
Esri Contributor

It looks like the Topo basemap you're referencing is a vector tile basemap. Those are different and have a different download task (`ExportVectorTilesTask`) and download a different format (.vtpk) which may or may not be what you want.

The export enabled image tiled version of the Topo basemap is here:

https://www.arcgis.com/home/item.html?id=eaee8760ed754019a964a6d785613a50

 if you want to give that a shot. That should work with the code you have.

DaxtonHorspool
New Contributor

This did the trick! Thanks, I was not understanding the difference between Vector and Tiled. On a side note, which one typically allows more tiles to be taken offline? I know most Tiled state about 100,000 - 150,000. I noticed the vector's only say: "support exporting small volumes of basemap tiles for offline use " though. Thanks again for the help!

0 Kudos
GregDeStigter
Esri Contributor

Glad to hear its working.

The vector tile export limit is technically controlled by the service so there's not a general number we can give, but

export limits are typically about the same between image and vector services - at least for Esri basemaps. However, since the vector tiles are vector-based and not image-based they tend to be significantly smaller than their image tile counterparts.

The service specific vector tile export limit is contained in the maxExportTilesCount of the VectorTileService metadata (REST doc). You can get that by viewing the service URL in a browser or by creating and loading an ArcGISVectorTiledLayer in the Runtime API and checking the SourceInfo.MaxExportTilesCount property.

0 Kudos