Map Snapshot
The Map SDK supports capturing the current screen area displayed on the map. You can take a screenshot that includes the map, overlays (including info windows), and the logo. Note that map controls and Toast windows are not captured.
The following example demonstrates how to implement this feature:
/**
* Takes a screenshot of the map.
*/
aMap.getMapScreenShot(new OnMapScreenShotListener() {
@Override
public void onMapScreenShot(Bitmap bitmap) {
// Handle the screenshot bitmap
}
@Override
public void onMapScreenShot(Bitmap bitmap, int status) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
if (null == bitmap) {
return;
}
try {
FileOutputStream fos = new FileOutputStream(
Environment.getExternalStorageDirectory() + "/test_"
+ sdf.format(new Date()) + ".png");
boolean b = bitmap.compress(CompressFormat.PNG, 100, fos);
try {
fos.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
StringBuffer buffer = new StringBuffer();
if (b)
buffer.append("Screenshot succeeded ");
else {
buffer.append("Screenshot failed ");
}
if (status != 0)
buffer.append("Map rendering complete, screenshot has no grid lines");
else {
buffer.append("Map rendering incomplete, screenshot has grid lines");
}
ToastUtil.show(getApplicationContext(), buffer.toString());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
});