简体   繁体   English

如何通过单击超链接打开google map应用

[英]how to open google map app by clicking on a hyperlink

I have made an WebView android application. 我已经做了一个WebView android应用程序。 And on a website i have given a link MAP where user clicks and it will take to the google map. 并在一个网站上,我给了一个链接MAP,用户单击该链接即可进入Google地图。

I want that if a user clicks on MAP link from the android application or website so the google MAPS application GPS live address tracking which will open outside the application not the site inside the android app. 我希望,如果用户从android应用程序或网站上单击MAP链接,则google MAPS应用程序GPS实时地址跟踪将在应用程序外部而不是android应用程序内部的站点打开。

I am using the code below: 我正在使用以下代码:

<a  
href="http://maps.google.com/?f=q&source=s_q&hl=en&geocode=&q=<?php echo $eAddr; ?>&z=17"
>Show Map</a>

you can implement the shouldOverrideUrlLoading method http://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading(android.webkit.WebView , java.lang.String) 您可以实现shouldOverrideUrlLoading方法http://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading(android.webkit.WebView,java.lang.String

and do something like 并做类似的事情

webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new MyWebViewClient());

...

private class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if(uri.startsWith("http://maps.google.com")) {
          Uri uri = Uri.parse(url);
          Intent intent = new Intent(Intent.ACTION_VIEW, uri);
          startActivity(intent);
        }

        return true;
    }
}   

Don't have a chance to test now, but it should work in theory 现在没有机会进行测试,但理论上应该可行

Good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM