开发者

Show google map in web view

In my application i want to show Google map with search result in web开发者_开发百科 view. for example i want to search pizza in Texas. So i want to show Google map with already searched result for pizza Texas.


do like this

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


Use this:

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

Or copy paste the maps.google.com url in this snippet to goto the browser:

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜