arcgis-android:100.10.0
code:
setContentView(R.layout.activity_main);
// retrieve the MapView from layout
mMapView = findViewById(R.id.mapview);
// create a raster from a local raster file
Raster raster = new Raster(Environment.getExternalStorageDirectory().getAbsolutePath() + "/tiffiles/raster-file/Shasta.tif");
// create a raster layer
final RasterLayer rasterLayer = new RasterLayer(raster);
// create a Map with imagery basemap
ArcGISMap map = new ArcGISMap(BasemapStyle.ARCGIS_IMAGERY);
// add the map to a map view
mMapView.setMap(map);
// add the raster as an operational layer
map.getOperationalLayers().add(rasterLayer);
// set viewpoint on the raster
rasterLayer.addDoneLoadingListener(() -> mMapView.setViewpointGeometryAsync(rasterLayer.getFullExtent(), 50));
error:
java.lang.IllegalArgumentException: Parameter boundingGeometry must not be null
I suspect that this is failing as there was an issue loading the raster. The code above could be improved by checking the load status of the file before setting the view point. In my own app, I did the following:
// set viewpoint on the raster
rasterLayer.addDoneLoadingListener(() -> {
// check to see if the file loaded
if (rasterLayer.getLoadStatus() == LoadStatus.LOADED) {
mapView.setViewpointGeometryAsync(rasterLayer.getFullExtent(), 150);
} else {
// it didn't load so let's examine the load errors outputting results from these methods:
rasterLayer.getLoadError().getMessage();
rasterLayer.getLoadError().getCause();
}
});
So output the errors to Logcat and see what is happening.
It is possible you don't have permission to read the files from your local storage...
Let me know if this helps.
Thanks
Mark
Thanks for reply my question!I logcat the message,it shows E/getMessage:: Unlicensed feature.
As i think i need check my license
my tif foried to deleted setLicense and got new error.
2021-04-06 10:49:03.306 17747-17747/com.example.offlinemapdemo E/getMessage:: File error.
2021-04-06 10:49:03.306 17747-17747/com.example.offlinemapdemo E/getCause:: null
my tif folder has 4 files:Shasta.tfw ;Shasta.tif ; Shasta.tif.aux.xml ;Shasta.tif.ovr。
and my app has permission to read the local files
May I ask where the problem may be?