I am trying add raster layer like tiff to the map, and I use the following code:
FileRasterSource rasterSource = new FileRasterSource(file); final RasterLayer rasterLayer = new RasterLayer(rasterSource); mMapView.addLayer(rasterLayer);
It works, however once I want to set the layer to fill the veiewport of the map:
mMapView.setExtent(rasterLayer.getExtent());
It does not work.
And what's more, I found that the map can not be zoom out at a certain scale. I am not sure why.
You may want to listen for when the map status has changed, then call setExtent on the mMapView when the raster layer has finished loading. Consider the following...
mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
@Override
public void onStatusChanged(Object source, STATUS status) {
if(source instanceof RasterLayer && STATUS.LAYER_LOADED == status){
mMapView.setExtent(rasterLayer.getExtent(), 2);
}
}
});
In fact I am using the listener at the moment, and it does not work as expectd.
1) I can not see the map unless I zoom in the map.
2) The map will disappear once the map scale is smaller than a certain value.