Google マップと地理位置情報を使用する Web サイトのラッパー アプリを作成しています。私が遭遇した問題は、通常のブラウザーではページが正常に機能することですが、WebView では 2 本指のズームが機能せず、文字通りログに次のエラーが表示されます。
05-24 08:14:28.504: E/Web Console(21166): Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null at http://<mydomain>/index.php:28
問題は、関数が Google の JS コードでのみ使用され、私たちのコードでは使用されていないことです。これを解決するにはどうすればよいですか?
これは、検閲を最小限に抑えた、(おそらく)関連するソースです。
myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
mk.setTitle(getString(R.string.loading));
mk.setProgress(progress * 100);
if(progress == 100) {
mk.setTitle(R.string.app_name);
}
}
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);
}
});
myWebView.setWebViewClient(new MyWebViewClient());
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setUserAgentString(getString(R.string.useragent));
webSettings.setGeolocationEnabled(true);
webSettings.setBuiltInZoomControls(false);
webSettings.setGeolocationDatabasePath("/data/data/com.mypackage.myapp");
myWebView.addJavascriptInterface(new JSInterface(this), "androidapp");
myWebView.loadUrl(HOMEURL);