从Android的地图快照 [英] Snapshot from the map in android
本文介绍了从Android的地图快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要调用的意图或从mapview.Can任何人能帮助我。我很没有得到快照,使从地图上的特定位置的快照。
I want to make a snapshot of a particular location from the map by calling intent or from a mapview.Can anyone help me.I am not getting the snapshot.
推荐答案
尝试的这个后,我相信这应该帮助。它包括使绘图缓存并强制其使用该缓存。通常适用于所有的意见。应工作在图形页面
藏汉
Try this post, I believe this should help. It involves enabling the drawing cache and forcing it use that cache. Usually works on all views. Should work on MapView
aswell
从链接code
private Bitmap getMapImage() {
/* Position map for output */
MapController mc = mapView.getController();
mc.setCenter(SOME_POINT);
mc.setZoom(16);
/* Capture drawing cache as bitmap */
mapView.setDrawingCacheEnabled(true);
Bitmap bmp = Bitmap.createBitmap(mapView.getDrawingCache());
mapView.setDrawingCacheEnabled(false);
return bmp;
}
private void saveMapImage() {
String filename = "foo.png";
File f = new File(getExternalFilesDir(null), filename);
FileOutputStream out = new FileOutputStream(f);
Bitmap bmp = getMapImage();
bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
out.close();
}
这篇关于从Android的地图快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文