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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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 from the link
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();
}