pakuti
pakuti

Reputation: 57

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.

Upvotes: 1

Views: 7880

Answers (3)

Anil M H
Anil M H

Reputation: 3342

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

Upvotes: 0

Ajay Singh
Ajay Singh

Reputation: 1621

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

Upvotes: 1

Mark Mooibroek
Mark Mooibroek

Reputation: 7696

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

Upvotes: 1

Related Questions