how to get snapshot from Google Map V2

戏子无情 提交于 2019-12-24 00:34:57

问题


I am wondering to know about how to get snapshot from SupportMapFragment. I have no idea. Please help.

Thanks for your advance.


回答1:


You can try to take a screen shot of the fragment View:

 View view = findViewById(R.id.fragmentId);
 view.setDrawingCacheEnabled(true);
 Bitmap bitmap = view.getDrawingCache();
 BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);

I haven't tested it.




回答2:


To get a drawable you can implement this code:

SnapshotReadyCallback callback = new SnapshotReadyCallback() {
    @Override
    public void onSnapshotReady(Bitmap snapshot) {
        mapSnapshot = snapshot;
    }
};

googleMap.snapshot(callback);

Drawable screenshot = new BitmapDrawable(getResources(),mapSnapshot);

If you directly want to save the snapshot on the SD, you can follow this answer: Capture screen shot of GoogleMap Android API V2




回答3:


The latest update of Google Play Services library brings us ability to make snapshots via GoogleMap's snapshot() method.



来源:https://stackoverflow.com/questions/16435842/how-to-get-snapshot-from-google-map-v2

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