在Web视图中显示谷歌地图

时间:2011-04-06 10:39:00

标签: android

在我的应用程序中,我想在Web视图中显示带有搜索结果的Google地图。例如,我想在德克萨斯州搜索披萨。所以我想显示已经搜索过的披萨德克萨斯结果的谷歌地图。

3 个答案:

答案 0 :(得分:1)

使用此:

StringBuilder u = new StringBuilder();
u.append("geo:0,0?q=");
u.append("Pizza, Texas");

Intent mapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(u.toString()));
startActivity(mapIntent);

或者复制粘贴此代码段中的maps.google.com网址以转到浏览器:

Intent browseIntent = new Intent(Intent.ACTION_VIEW, Uri.parse( YOUR-URL-HERE ));
startActivity(browseIntent);

答案 1 :(得分:1)

喜欢这个

private WebView                 _webView;

    _webView = (WebView)_yourrelativelayourSrc.findViewById(R.id.layout_webview);

    _webView.getSettings().setJavaScriptEnabled(true);
    _webView.getSettings().setBuiltInZoomControls(true);
    _webView.getSettings().setSupportZoom(true);

    _webView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            // Activities and WebViews measure progress with different scales.
            // The progress meter will automatically disappear when we reach 100%
            ((Activity) activity).setProgress(progress * 1000);
        }

    });

    // to handle its own URL requests :
    _webView.setWebViewClient(new MyWebViewClient());
    _webView.loadUrl("http://maps.google.com/maps?q=Pizza,texas&ui=maps");

答案 2 :(得分:0)

private static final String latitude =“12.292037”; private static final String longitude =“76.641601”;

webView = (WebView) findViewById(R.id.webView1); webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl("http://www.google.com/maps?q="+latitude+","+longitude);