Select to view content in your preferred language

ExportTileCacheTaskSampleActivity.java

2901
4
03-17-2014 08:53 PM
michaelsamuels
Emerging Contributor
I'm trying to make the ExportTileCacheTaskSampleActivity (as found at https://developers.arcgis.com/android/sample-code/export-tile-cache/) work.

I found the page that features a set of tiled basemap services that can be used to export tile packages for offline use. (http://www.arcgis.com/home/group.html?owner=esri&title=Tiled%20Basemaps).

When I try to use the sample with any of the maps listed at that page, I got the following error:

com.esri.core.io.EsriSecurityException: Unauthorized access to a secure service - http://tiledbasemaps.arcgis.com/arcgis/rest/services/USA_Topo_Maps/MapServer/exportTiles/submitJob

So I realized that I had to supply User Credentials (the free trial/developer account I had created) to the constructor of ExportTileCacheTask ... and it worked!  I got my files.

Now, however, I can't get anything to display.  I just see grid lines.


Mike
0 Kudos
4 Replies
ShellyGill1
Esri Contributor
Hi Mike,

I have not seen this issue specifically, but I can suggest a few things I would try.

Make sure you're setting map extent or zooming in and out to the levels that you actually exported to the TPK. Also check you you did load the layer correctly - check the layer got initialized for example using MapView.getOnStatusChangedListener.

Try loading an existing TPK file into your map with the same code - e.g. http://www.arcgis.com/home/item.html?id=4497b7bb42e543b691027840d1b9092a. Or try making an ArcGIS Compact Cache output instead of a TPK to see if that makes any difference.

If yo have no luck I would post your generated TPK here so we could try loading it and see if we have same problems.

Regards
0 Kudos
michaelsamuels
Emerging Contributor
Shelly,
The TPK file that I downloaded from  http:http://www.arcgis.com/home/item.html?id=4497b7bb42e543b691027840d1b9092a worked great!  So, there must be something wrong with my file.

I am posting my "compact cache" files, and my TPK file.

Thanks,
Mike

P.S. - Perhaps this is something:  I'm not clear what the levels parameter in the ExportTileCacheParameters is supposed to be.  Per the sample code, it's an array of doubles containing 1.0, 2.0, 3.0 ... and so forth.  Is that correct?
0 Kudos
DanO_Neill
Deactivated User
You are most likely seeing the grid because you are not zoomed into the Level of Detail you downloaded.Did you attempt to download without selecting levels in the sample?  A quick look at the layer compact cache you attached shows you downloaded levels 0 - 9 and your json description is valid. Did you select those 10 levels? I noticed that the sample will start the download if you have not selected levels which I will fix and republish. 

You are correct in suspecting that the levels parameter are doubles representing the level of detail available in the tile service.  The service provided in the sample has 10 levels of detail available as described in the service description here.
0 Kudos
michaelsamuels
Emerging Contributor
Thanks, Dan.  That did it. 
It was indeed a matter of setting the resolution correctly.  Mind you, I didn't know what resolution to set it to, since I couldn't find documentation for this in the map I'm using (http://tiledbasemaps.arcgis.com/arcgis/rest/services/NatGeo_World_Map/MapServer). So, I had to first get the map into view (by using hand gestures to zoom in and zoom out), and then, in a debug point, I did a mapView.getResolution().

Whew!

The whole process is exacerbated by the fact that it takes over a minute for Android to do a compile, due (I presume) to the fact that it re-compiles ArcGIS' library each time.  Have you encountered this?  And if so, have you figured out a way to get around this?

Mike.

P.S. - thanks for your help!
0 Kudos