Android Google Maps/Earth打开本地KML/KMZ文件并播放游览功能 [英] Android Google Maps/Earth opening Local KML/KMZ file and play the tour functionality

查看:278
本文介绍了Android Google Maps/Earth打开本地KML/KMZ文件并播放游览功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Android的Google Maps/Earth应用程序中打开本地KML/KMZ文件?尝试了以下方法,但没有用.

Is there a way to open a local KML/KMZ file in Google Maps/Earth app on Android? Tried the below approach but didn't work.

    Intent mapIntent = new Intent(Intent.ACTION_VIEW);
    Uri uri1 = Uri
            .parse("geo:0,0?q=file:///mnt/sdcard/doc.kml");
    mapIntent.setData(uri1);
    startActivity(Intent.createChooser(mapIntent, "Sample"));

如果没有,并且如果我们只能指定网络上托管的链接,那么我们可以指定指向Google云端硬盘文件的链接以直接在Google Maps/Earth上显示吗?

If not and if we can specify only links that are hosted on the web then can we specify a link to the Google Drive file to show directly on Google Maps/Earth?

    Intent mapIntent = new Intent(Intent.ACTION_VIEW);
    Uri uri1 = Uri
            .parse("geo:0,0?q=https://drive.google.com/open?id=0B8n3LAJCTg-8eml4TTBoZDlRd00&authuser=0");
    mapIntent.setData(uri1);
    startActivity(Intent.createChooser(mapIntent, "Sample"));

最后,Google Earth中的播放游览功能发生了什么?它曾经可以使用,但是最新的更新已损坏,不再起作用.

And finally what happened to the play tour functionality in Google Earth? It used to work but with the latest updates its broken and no longer working.

    File file = new File(playFileNameKml);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(file),
            "application/vnd.google-earth.kml+xml");
    intent.putExtra("com.google.earth.EXTRA.tour_feature_id", "tour");
    startActivity(intent);

推荐答案

这是刚刚为我工作的内容:

This is what has just worked for me:

Uri uriFromFile = FileProvider.getUriForFile(Install_sinapseActivity.this, GenericFileProvider.class.getName(), file); try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uriFromFile, "application/vnd.google-earth.kml+xml"); intent.putExtra("com.google.earth.EXTRA.tour_feature_id", "my_track"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(intent); catch (ActivityNotFoundException e) { ... }

Uri uriFromFile = FileProvider.getUriForFile(Install_sinapseActivity.this, GenericFileProvider.class.getName(), file); try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uriFromFile, "application/vnd.google-earth.kml+xml"); intent.putExtra("com.google.earth.EXTRA.tour_feature_id", "my_track"); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(intent); catch (ActivityNotFoundException e) { ... }

这篇关于Android Google Maps/Earth打开本地KML/KMZ文件并播放游览功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆