I am trying to show a map which animates percentages for several areas on the map. But the javascript (which works in the browser) doesn't show any animation or percentage at all. The webmpa.generateJs() generates the javascript to animate the percentages and the function initialize is used to draw the map.
WebSettings settings = webView.getSettings();
settings.setAppCacheEnabled(true);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setJavaScriptEnabled(true);
final WebMap webMap = new WebMap();
webView.addJavascriptInterface(webMap.getInterface(getActivity().getApplication(),this), "Android");
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
Log.d(TAG,webMap.generateJs());
webView.loadUrl("javascript:" + webMap.generateJs());
webView.loadUrl("javascript:initialize();");
}
});
webView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
webView.setBackgroundColor(Color.TRANSPARENT);
webView.loadUrl(MAP_URL);
You have to use WebChromeClient for your purpose.
webView.setWebChromeClient(new WebChromeClient());
This may helps you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With