如何获得MapView类的位图来自谷歌Android地图API V2 [英] How to get Bitmap of MapView from Android Google Maps API V2

查看:110
本文介绍了如何获得MapView类的位图来自谷歌Android地图API V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新我的应用程序,以全新的Andr​​oid地图API V2,并试图让当前显示的地图的位图图像时,遇到了一个问题。在API V1我这样做,像这样:

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在API V1,这让我在地图上的位图,在API V2,我得到的是一个黑色的矩形。

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

另外随着API V2我使用了图形页面,而不是 MapFragment 所以这不是问题

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

推荐答案

<一个href="https://developer.android.com/reference/com/google/android/gms/maps/GoogleMap.html#snapshot%28com.google.android.gms.maps.GoogleMap.SnapshotReadyCallback%29"相对=nofollow> GoogleMap.snapshot()方法做这项工作。

这篇关于如何获得MapView类的位图来自谷歌Android地图API V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆