The map from local .TPK file is displayed only after I zoom it, Android SDK 100.15.4

338
2
Jump to solution
03-02-2024 10:36 PM
RobertAnisoiu1
New Contributor II

Hello,

I had an Android application that display a local .TPK file,, stored on the phone.

Starting with Android 14 the application does not start and I made an upgrade to ArcGis Runtime SDK 100.15.4

Now the map is displayed but I need to zoom it in order to make it visible. When the map is launched, the screen is with Esri grid, but the map is not visible. As soon as I was zoom it, the map become visible and I can zoom in or zoom out.

I think there is a scale issue or something like that. I read a lot but I did not found any relevant information. 

Have you any idea?

The code is below:

MapView mmapView = findViewById(R.id.mapView);
ArcGISRuntimeEnvironment.setApiKey(API_KEY);
 
String extDirName =Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + File.separator + "Folder/";

String filename ="myTPK.tpk";
String tpkFile = extDirName + filename;
TileCache tileCache = new TileCache(tpkFile);
ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tileCache);
Basemap basemap = new Basemap(tiledLayer);
ArcGISMap map = new ArcGISMap(basemap);
mmapView.setMap(map);
mmapView.setVisibility(View.VISIBLE);
mmapView.setWrapAroundMode(WrapAroundMode.ENABLE_WHEN_SUPPORTED);
2 Solutions

Accepted Solutions
GuntherHeppner
Esri Contributor

Hi Robert,

This is likely related to the scale range (min/max scale) of your tpk data. You should be able to find out what the scale range is, by either:
- Reading the values of ArcGISTiledLayer.minScale & ArcGISTiledLayer.maxScale once the layer has loaded.

- Or by reading the TileInfo obtained from ArcGISTiledLayer.tileInfo once the layer has loaded. TileInfo.levelsOfDetail gives you access to each LevelOfDetail which in turn gives you the scale values of each level. 

Once you know the min/max scale of your ArcGISTiledLayer you can set these properties on your ArcGISMap instance with ArcGISMap.minScale & ArcGISMap.maxScale. The MapView will then apply that min scale upon initial drawing of the map so your map should appear at the appropriate tile level from the start.

See related post: https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/how-to-calculate-min-and-max-...

related sample: https://developers.arcgis.com/android/kotlin/sample-code/set-min-max-scale/

View solution in original post

0 Kudos
RobertAnisoiu1
New Contributor II

Thank you for all your help, Gunther. The problem was solved. By setting a minimum scale in application, the map become visible when the application is open.  The code is below

map.setMinScale(150000);

  

View solution in original post

2 Replies
GuntherHeppner
Esri Contributor

Hi Robert,

This is likely related to the scale range (min/max scale) of your tpk data. You should be able to find out what the scale range is, by either:
- Reading the values of ArcGISTiledLayer.minScale & ArcGISTiledLayer.maxScale once the layer has loaded.

- Or by reading the TileInfo obtained from ArcGISTiledLayer.tileInfo once the layer has loaded. TileInfo.levelsOfDetail gives you access to each LevelOfDetail which in turn gives you the scale values of each level. 

Once you know the min/max scale of your ArcGISTiledLayer you can set these properties on your ArcGISMap instance with ArcGISMap.minScale & ArcGISMap.maxScale. The MapView will then apply that min scale upon initial drawing of the map so your map should appear at the appropriate tile level from the start.

See related post: https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/how-to-calculate-min-and-max-...

related sample: https://developers.arcgis.com/android/kotlin/sample-code/set-min-max-scale/

0 Kudos
RobertAnisoiu1
New Contributor II

Thank you for all your help, Gunther. The problem was solved. By setting a minimum scale in application, the map become visible when the application is open.  The code is below

map.setMinScale(150000);