private void takeSnapshot() { if (mMap == null) { return; } final ImageView snapshotHolder = (ImageView) findViewById(R.id.snapshot_holder); final SnapshotReadyCallback callback = new SnapshotReadyCallback() { @Override public void onSnapshotReady(Bitmap snapshot) { // Callback is called from the main thread, so we can modify the ImageView safely. snapshotHolder.setImageBitmap(snapshot); } }; if (mWaitForMapLoadCheckBox.isChecked()) { mMap.setOnMapLoadedCallback(new OnMapLoadedCallback() { @Override public void onMapLoaded() { mMap.snapshot(callback); } }); } else { mMap.snapshot(callback); } }
@Override public void snapshot(SnapshotReadyCallback callback) { map.snapshot(callback); }
@Override public void snapshot(SnapshotReadyCallback callback, Bitmap bitmap) { map.snapshot(callback, bitmap); }