2

GooglePlayServices 的最新版本 (12) 包含用于截屏地图的文档 ( https://developers.google.com/maps/documentation/android/releases#august_2013 )。这是我尝试过的代码,但仍然出现黑屏:

public void captureMapScreen() {
    SnapshotReadyCallback callback = new SnapshotReadyCallback() {
        Bitmap bitmap;

        @Override
        public void onSnapshotReady(Bitmap snapshot) {
            bitmap = snapshot;
            try {
                FileOutputStream out = new FileOutputStream("/mnt/sdcard/" + "MyMapScreen" +
                                                            System.currentTimeMillis() + ".png");

                // above "/mnt ..... png" => is a storage path (where image will be stored) + name of image you can
                // customize as per your Requirement

                bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
    GoogleMap googleMap = getMap();
    googleMap.snapshot(callback);
}

在此处输入图像描述

4

0 回答 0