2

I am wondering to know about how to get snapshot from SupportMapFragment. I have no idea. Please help.

Thanks for your advance.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
Ferdinand
  • 1,193
  • 4
  • 23
  • 43

3 Answers3

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

Community
  • 1
  • 1
Lmoro
  • 71
  • 3
1

The latest update of Google Play Services library brings us ability to make snapshots via GoogleMap's snapshot() method.

Alexander Mironov
  • 3,095
  • 26
  • 28
0

You can try to take a screen shot of the fragment View:

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

I haven't tested it.

Emil Adz
  • 40,709
  • 36
  • 140
  • 187