android - 如何在 android 的 webview 中显示本地谷歌地图?

标签 android google-maps android-webview

我有以下代码来显示 webview:

webview.xml

<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

WebViewActivity.java

public class WebViewActivity extends Activity {

    private WebView webView;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        webView = (WebView) findViewById(R.id.webView1);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("http://maps.google.com/maps?" +"saddr=43.0054446,-87.9678884" + "&daddr=42.9257104,-88.0508355");
    }
}

我想在 WebView 中打开以下代码:

final Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?" + "saddr=43.0054446,-87.9678884" + "&daddr=42.9257104,-88.0508355"));
intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent);

我该怎么做?

最佳答案

请查看this .它不会在 WebView 中打开 native Google Map 应用程序,而是加载 http://maps.google.com/maps?~~在 WebView 中。

可能有帮助。

关于android - 如何在 android 的 webview 中显示本地谷歌地图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9962469/

相关文章:

javascript - 有没有办法使用 android cordova 应用程序将文件上传到共享的谷歌驱动器文件夹?

javascript - AngularJS $http.jsonp() 方法访问 Google map 距离矩阵 API

android - 如何在 Android 模拟器中更新 Google Play 服务

android - android sdk 需要 android developer toolkit 版本 22.6.1 或以上

android - fragment 上的 IllegalStateException 替换为动画

Android WebView iFrame 字体缩放

android - 音频和视频未在 Android WebView HTML5 中播放

java - 如何在webview中实现后退按钮?

android - 如何停止在 Android Studio 中构建的 Android 应用程序等待调试器附加?

javascript - 从地址获取经纬度并写入文件