how to get snapshot from Google Map V2
Asked Answered
D

3

2

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

Thanks for your advance.

Deuteragonist answered 8/5, 2013 at 8:21 Comment(0)
C
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.

Cottrell answered 8/5, 2013 at 8:24 Comment(2)
It does not work, I tested It, the screenshot output is black.Shire
@Shire is right.because we are draw map in google map object.so how i can take screenshot of googlemap with pin,draw route path etc.Millhon
D
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

Decade answered 4/5, 2014 at 0:33 Comment(0)
S
1

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

Subalternate answered 13/8, 2013 at 12:28 Comment(0)
C
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.

Cottrell answered 8/5, 2013 at 8:24 Comment(2)
It does not work, I tested It, the screenshot output is black.Shire
@Shire is right.because we are draw map in google map object.so how i can take screenshot of googlemap with pin,draw route path etc.Millhon

© 2022 - 2024 — McMap. All rights reserved.