Not able to export tiles for basemaps

4055
14
06-30-2019 11:52 PM
DevendraKhatri
New Contributor III

Requirement:

I need to provide basemaps in offline mode, I should be able to download basemap's tiles in mobile device and use it when no connectivity.

My scenarios:

1. I create the feature with ESRI's default basemap, I use the OfflineMapTask on mobile,  I am not able to download .vtpk file.

2. I create my custom base layer on developers portal, create feature with it, when I use the OfflineMapTask on mobile I am able to download .vtpk file

Observation in Arcgis online layer settings page:

1. Default basemap's setting page is different from that of custom basemap. Setting page for custom basemap shows me tile's datasource, for default basemap it gives me option to build tiles !!

Another observation with using rest api [../exportTiles?tilePackage=true&exportExtent=-13051380,4030276,-13037288,4041136&optimizeTilesForSize=true&compressionQuality=60&exportBy=levelId&levels=13-19&areaOfInterest=&f=json ]  

1. With default basemap it doesn't give me the jobid and it says    

{"error":{"code":400,"message":"Exporting tiles is not allowed.","details":[]}}

2. With custom basemap it  give me the jobid 

Question:

ESRI's default basemaps are not capable of downloading the tiles? or it requires any configuration !

0 Kudos
14 Replies
MarkBaird
Esri Regular Contributor

The workflow that we encourage is where you take your entire map offline.  This is where you map (basemap and operational layers) are hosted in ArcGIS Online.  This is introduced here:

https://developers.arcgis.com/android/latest/guide/work-with-offline-maps.htm

More detailed information including use of parameters here:

https://developers.arcgis.com/android/latest/guide/take-map-offline-ondemand.htm

https://developers.arcgis.com/android/latest/guide/take-map-offline-preplanned.htm

There is of course more fine grained API if you are only working with the basemap and not using a webmap.

I don't have an Android sample showing this, but here are a couple for JavaFX which you can easily adapt for Android:

https://developers.arcgis.com/java/latest/sample-code/export-tiles.htm

https://developers.arcgis.com/java/latest/sample-code/export-vector-tiles.htm

The parameters are explained in the JavaDoc and pretty simple:

https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/tasks/ti...

https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/tasks/ve...

The API makes it nice and easy, but if you want to understand what is happening under the covers in the Rest API then you can look at this:

https://developers.arcgis.com/rest/

Regarding coordinate systems, the data will be exported in the coordinate system of the basemap.  Typically these are Web Mercator.

You can of course pass in a parameter for the extent of the export area in another spatial reference (WGS84 lat, long for example), BUT make sure that you create your geometry stating the spatial reference!  If you don't it will assume the geometry is the same as the basemap and will give unwanted results!

Does this help

0 Kudos
DevendraKhatri
New Contributor III

Thanks Mark, it helps.

Also, let me set the context, I am using REST APIs to download tiles here..

I see this message very frequently that maximum tiles that I can download is set to 150000. How do I increase it because I need to set the levels to the max to show roads, how do I do this.

I see options to set exportBy in the URL  to resolution and scales , but these  always give me error of value required.

0 Kudos
Nicholas-Furness
Esri Regular Contributor

150,000 is the max number of tiles we allow to prevent the service being overwhelmed by requests and to prevent the file system filling up with large packages of tiles waiting to be downloaded. It is set by the service administrator. When publishing and hosting your own services, you can control this value but it is not user-configurable for our basemaps.

You can tell if you'll hit that limit by calling the estimate commands: Estimate Export Tile Size—ArcGIS REST API and Android estimateTileCacheSize().

When you have created an ExportTileCacheTask and pointed it at an Image Service and Loaded it, you can look at the Task's ArcGISMapServiceInfo to see what the max export tile count is (and for that matter if the service can even generate a TPK).

If you need to take larger areas offline, the hosted tiled services might not be the right approach for you. VTPKs will be more efficient in that scenario (but we limit the tiles you can take offline in that scenario too).

Taking the tiles offline is provided largely for Runtime app capabilities, so we encourage you to use those APIs. This forum isn't really the place to dig deep into the REST APIs.

Hope that helps,

Nick.

0 Kudos
DevendraKhatri
New Contributor III

Hi Nick/Mark,

I am using createReplica to download the geodatabases of the feature layers instead of Native APIs due to framework dependencies.

I see that the following url provides free feature layers, but I am not able to generate geodatabase out of it

https://cohegis.houstontx.gov/cohgis/rest/services/

are there sync-enabled public feature layer URLs available ?

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Could you explain the "framework dependencies"? I don't understand. If you're using the Runtime SDK, you have the capabilities at your fingertips.

If the service has a createReplica Supported Operation at the bottom of the page, which this services does not, then you can take a runtime geodatabase offline. You can see the PropertyData/PropertyData (MapServer) service doesn't include createReplica:

I'm sure there are many public services available which are offline enabled, but that's up to the owner/publisher of the data (in the case of the URL you provided, it looks like the City of Houston, Texas). See Publish hosted feature layers—ArcGIS Online Help | ArcGIS and ArcGIS for Developers - New Layer.

To enable your layers for offline use, see Manage hosted feature layers—Allow offline editing or collaboration 

0 Kudos