I am wondering to know about how to get snapshot from SupportMapFragment. I have no idea. Please help.
Thanks for your advance.
I am wondering to know about how to get snapshot from SupportMapFragment. I have no idea. Please help.
Thanks for your advance.
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.
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
The latest update of Google Play Services library brings us ability to make snapshots via GoogleMap's snapshot() method.