How to utilize multiple tpks in your map view

2402
1
10-11-2013 12:51 PM
JasonKnisley
Occasional Contributor
Recently I ran into two problems which seem to be limitations of the currently implementation of the ArcGIS Runtime SDK for Android, and so I thought I'd post this to let others know of a potential workaround.

Problems:

  1. I need an offline solution so I created a tpk of the imagery, but it's almost 25 GB and the SDK doesn't seem to read tpk files > 2GB.

  2. If I create multiple tpks that are each less than 2GB, the MapView extent gets locked to the extent of the first tpk and I can't pan to the others.

By creating several smaller tpks for my area of interest, I ended up with 8 tpks that only total 10 GB (ranging from 1.1 GB to 1.6 GB in size). The good news is that the SDK reads all of them just fine, and it also saves a lot total space since the tpks are all rectangular (envelope) extents, and the single tpk included large areas that I don't care about. However, I experienced the problem that I described above, whereby the MapView would initialize to the extent of the first tpk, and while I could see the edges of the adjacent tpks, I couldn't actually pan the MapView to see them all. Calling mapView.setExtent() didn't solve my problem, and neither did setting 'initExtent' in my layout.xml where I defined my MapView.

My solution? Before I loaded the tpks I added an empty ArcGISFeatureLayer as the first layer in my MapView, with a service definition that specifies an extent which covers all of my tpks. The code I used (which uses the Tennessee State Plane project and encompasses the Memphis area) is below. Based on my testing, your feature definition can omit all properties except for the extent.

In MyApplication/res/values/config.xml:
<string name="config.fullextent.definition">
{
\"extent\": {
    \"xmin\": 745209,
    \"ymin\": 258815,
    \"xmax\": 889493,
    \"ymax\": 413469,
    \"spatialReference\": {
        \"wkid\": 102736,
        \"latestWkid\": 2274
    }
}
}
</string>


In MyApplication/src/myPackage/myActivity.java:
// add layer to control the overall extent 
mMapView.addLayer(new ArcGISFeatureLayer(getResources().getString(R.string.config_fullextent_definition), new FeatureSet(), new Options()));

// add imagery layers
String[] imageryFiles = getResources().getStringArray(R.array.config_imagery_layers);
for (String imageryFile : imageryFiles) {
 mMapView.addLayer(new ArcGISLocalTiledLayer(String.format("file://%s%s", Environment.getExternalStorageDirectory(), imageryFile)));
}
0 Kudos
1 Reply
DanO_Neill
Occasional Contributor III
I will address the 2GB limitation you reference.  There is an issue in Android v10.1.1 and earlier that limits the size to 2GB which comes from our native library implementation.  We have a fix from in our native library in our upcoming 10.2 release which increases the file size limit to 2e64Bytes (~16777216TB).  While we will support such large file sizes, the ability to take advantage will depend on your device.  Limitations to 4GB exist in NTFS (2GB on FAT32) but increases with ext4 up to 16TB and exFAT.
0 Kudos