【问题标题】:how to get snapshot from Google Map V2如何从 Google Map V2 获取快照
【发布时间】:2013-05-08 08:21:16
【问题描述】:

我想知道如何从 SupportMapFragment 获取快照。我不知道。请帮忙。

感谢您的提前。

【问题讨论】:

    标签: android google-maps-android-api-2 supportmapfragment


    【解决方案1】:

    要获得可绘制对象,您可以实现以下代码:

    SnapshotReadyCallback callback = new SnapshotReadyCallback() {
        @Override
        public void onSnapshotReady(Bitmap snapshot) {
            mapSnapshot = snapshot;
        }
    };
    
    googleMap.snapshot(callback);
    
    Drawable screenshot = new BitmapDrawable(getResources(),mapSnapshot);
    

    如果您直接想将快照保存在SD上,您可以按照这个答案: Capture screen shot of GoogleMap Android API V2

    【讨论】:

      【解决方案2】:

      latest update of Google Play Services library 使我们能够通过 GoogleMap 的snapshot() 方法制作快照。

      【讨论】:

        【解决方案3】:

        您可以尝试截取片段视图的屏幕截图:

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

        我没有测试过。

        【讨论】:

        • 不行,我测试了一下,截图输出是黑色的。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-08-04
        • 1970-01-01
        • 1970-01-01
        • 2019-05-31
        • 2023-04-06
        • 1970-01-01
        • 2019-09-22
        相关资源
        最近更新 更多