-
Notifications
You must be signed in to change notification settings - Fork 75
Capture map image
jaakla edited this page Jan 16, 2015
·
3 revisions
To capture bitmap add following code. It saves it to a file, you may do different things with the Bitmap.
mapView.getComponents().mapRenderers.getMapRenderer().captureRendering(new MapRenderListener() {
@Override
public void onMapRendered(Bitmap bmp) {
FileOutputStream out = null;
try {
out = new FileOutputStream("/sdcard/sdkimg.png");
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
e.printStackTrace();
} finally {
try{
out.close();
} catch(Throwable ignore) {}
}
}
});
Make sure that it is called in good moment. onMapRendered makes sure it is called when map is rendered from OpenGL point of view, but the map data could be still partial or missing due to data loading. For example call in onCreate() would most probably give empty map view, as map tiles are not loaded yet, or you may get partial maps. Suggested place would be onBackgroundTasksFinished()
in your MapListener
.