WebView工作(缓慢)但与谷歌地图完全没有关系?

时间:2016-03-24 13:39:56

标签: android google-maps webview

我尝试使用WebView显示Google地图网页。如果我使用的目标网址类似于' http://www.google.co.uk'或者' http://www.youtube.com' webview有效,但不是在我使用' http://www.google.co.uk/maps/dir//NEC,+North+Avenue,+Birmingham/'

WebView无法使用地图网址并显示空白框

Java类:

public class location_Fragment extends Fragment {

private WebView webView;

View rootview;

@Nullable
@Override

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    rootview = inflater.inflate(R.layout.location_layout, container, false);
    webView = (WebView)rootview.findViewById(R.id.webView);

    webView.setWebViewClient(new MyBrowser());
    WebSettings webSettings = webView.getSettings();
    webSettings.setBuiltInZoomControls(true);
    webSettings.setJavaScriptEnabled(true);

    webView.loadUrl("http://www.google.co.uk/maps/dir//NEC,+North+Avenue,+Birmingham/");
    return rootview;
}

private class MyBrowser extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }
}

}

的AndroidManifest.xml:

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package= ... >

 <uses-permission android:name="android.permission.INTERNET" />

 <application ...
 </application>

 </manifest>

0 个答案:

没有答案