Snapshot from the map in android

巧了我就是萌 提交于 2019-12-10 00:16:44

问题


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();  
    }  


来源:https://stackoverflow.com/questions/8938659/snapshot-from-the-map-in-android

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