开发 Maps SDK for Android Guides Controls and Gestures Map Snapshot

Map Snapshot 最后更新时间: 2026年07月02日

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();
        }
    }
});

返回顶部 示例中心 常见问题 智能客服 公众号 高德开放平台公众号二维码 开放平台 扫码关注官方公众号