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:
- 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.
- 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)));
}