But " /> But " /> But "/>

I can't get image from Google Map with help of Drawing Cache in Android Studio

446 Views Asked by At

I have this code in layout:

<FrameLayout>    
        <fragment
            ...
            android:name="com.google.android.gms.maps.SupportMapFragment">
        </fragment>    
</FrameLayout>

But when i try use drawing cache, screenshot have only zoom bar (with + and - buttons) and text "Google" in left corner. I use next code for getting image:

View view = findViewById(R.id.frame);
view.setWillNotCacheDrawing(false);
view.destroyDrawingCache();
view.buildDrawingCache();
view.setDrawingCacheEnabled(true);
routeScreen = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
1

There are 1 best solutions below

0
Tanner Perrien On BEST ANSWER

The reason for this is because the map is drawn using OpenGL and the pixel data is stored in the GPU.

Have a look at Google Map's GoogleMap.snapshot() method in order to capture a screenshot of the map.