Search code examples
androidgoogle-mapswebviewbitmapscreenshot

How to take screen-shots of map in web view


I got screen-shot of map from view view, map is showing properly but markers are not showing in screen-shot.

RelativeLayout rlShare; 
rlShare.setDrawingCacheEnabled(true);
rlShare.buildDrawingCache(true);
Bitmap b = rlShare.getDrawingCache();

Solution

  • This happens because your WebView is being hardware accelerated and markers are being drawn on the hardware level.

    You can specify that the view has a software layer using View.LAYER_TYPE_SOFTWARE:

    yourWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);