How to take a screenshot of mapview in a Android App?
I want to take a screenshot of mapview, just mapview. I use getDrawingCache(), but the part of mapview is black.
@zhangkaiyue0701
This is because our map is using TextureView (<=v4.2.0) or a SurfaceView (v=4.2.0-beta.1).
If you want to make a screenshot/snapshot of the currently displayed map use mapboxMap#snapshot. This method will return a bitmap of the shown map content. Here is an example with an onClickListener and an ImageView:
@Override
public void onClick(View v) {
mapboxMap.snapshot(new MapboxMap.SnapshotReadyCallback() {
@Override
public void onSnapshotReady(Bitmap snapshot) {
ImageView snapshotView = (ImageView) findViewById(R.id.imageView);
snapshotView.setImageBitmap(snapshot);
}
});
}
Thank you for requesting help, feel free to reach out again. Above code snippet should resolve your issue. Closing.
Taking a snapshot does not include the polylines in it.
Have you guys added support for polylines or not?