我有以下代码来显示 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/