How to get Bitmap of MapView from Android Google Maps API V2

末鹿安然 提交于 2019-11-30 03:10:58

问题


I'm updating my app to the new Android Maps API V2 and ran into a problem when trying to get a bitmap image of the currently shown map. In API V1 I did this like so:

Bitmap mBitmap;
MapViwe mMapView;
// ...
mBitmap = Bitmap.createBitmap(MAP_WIDTH, MAP_HEIGHT, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(mBitmap);
mMapView.draw(canvas);

Whilest in API V1, this got me a bitmap of the map, in API V2, all I get is a black rectangle.

Also with API V2 I'm using the MapView, not the MapFragment so this isn't the problem.


回答1:


GoogleMap.snapshot() method does the job.



来源:https://stackoverflow.com/questions/14396587/how-to-get-bitmap-of-mapview-from-android-google-maps-api-v2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!