2011-04-06 74 views
1

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

回答

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"); 
+0

此方法仍然适用于Google Map上的新网页设计吗?我不断收到完整的网页,而不仅仅是地图。 – RobGThai 2012-07-26 18:00:29

+0

好问题,抢劫。我只想让地图不是完整的网页。 – topwik 2013-01-10 22:29:27

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); 
0

私人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);