2

我想知道如何从 SupportMapFragment 获取快照。我不知道。请帮忙。

感谢您的提前。

4

3 回答 3

2

To get a drawable you can implement this code:

SnapshotReadyCallback callback = new SnapshotReadyCallback() {
    @Override
    public void onSnapshotReady(Bitmap snapshot) {
        mapSnapshot = snapshot;
    }
};

googleMap.snapshot(callback);

Drawable screenshot = new BitmapDrawable(getResources(),mapSnapshot);

If you directly want to save the snapshot on the SD, you can follow this answer: Capture screen shot of GoogleMap Android API V2

于 2014-05-04T00:33:11.423 回答
1

Google Play 服务库的最新更新使我们能够通过 GoogleMap 的snapshot()方法制作快照。

于 2013-08-13T12:28:33.380 回答
0

您可以尝试截取片段视图的屏幕截图:

 View view = findViewById(R.id.fragmentId);
 view.setDrawingCacheEnabled(true);
 Bitmap bitmap = view.getDrawingCache();
 BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);

我没有测试过。

于 2013-05-08T08:24:48.273 回答