2013-10-01 36 views
1

我有一個奇怪的問題...我有一個服務器API,我已經安裝了JVectorMap javascripts來顯示地圖上的一些統計數據。這是非常簡單的我只需要在URL設置爲網頁視圖這樣的:WebView控制檯在android <4.0 |上顯示錯誤(JVectorMap)

(的WebView配置)

WebView wv = (WebView)lv_header.findViewById(R.id.result_webview); 

WebSettings settings = wv.getSettings(); 
settings.setBuiltInZoomControls(false); 
settings.setUseWideViewPort(true); 
settings.setJavaScriptEnabled(true); 
settings.setLoadsImagesAutomatically(true); 
settings.setDomStorageEnabled(true); 
settings.setLoadWithOverviewMode(true); 
wv.setHorizontalScrollBarEnabled(false); 

的WebView方法我打電話顯示地圖

private void setWebView(String countryCode) { 
wv.loadUrl(MyApplication.API_URL_SERVER_PRODUCTION+"/query/"+getIdFromPos(array_id, posInArray)+"/map/"+countryCode); 
} 

在Android 4.x版>將顯示確定一切正常,但在4.x下我有這個日誌; (和Webview是空白):

E/Web Console(8411): Uncaught TypeError: Object #<an HTMLDocument> has no method: 'createStyleSheet' at http://www.miwebsite.com/static/js/jvectormap/jquery-jvectormap-1.2.2.min.js:7 

法 'createStyleSheet' 這是在 「jQuery的jvectormap-1.2.2.min.js」 文件...

地圖的例子==>Click Here

回答

0

在jVectorMap未壓縮有在線路#javascript函數document.createStyleSheet()呼叫182:

jvm.VMLElement.initializeVML = function() { 
     try { 
      document.namespaces.rvml || document.namespaces.add("rvml", "urn:schemas-microsoft-com:vml"), jvm.VMLElement.prototype.createElement = function (e) { 
       return document.createElement("<rvml:" + e + ' class="rvml">') 
      } 
     } catch (e) { 
      jvm.VMLElement.prototype.createElement = function (e) { 
       return document.createElement("<" + e + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">') 
      } 
     } 
     document.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"), jvm.VMLElement.VMLInitialized = !0 
    } 

函數沒有被jVectorMap具體而言,是特定於第e IE在IE瀏覽器中的實現,直到IE 11.可能你使用的瀏覽器不支持這個功能(也許你正在從你的Android瀏覽器發送IE用戶代理字符串)。

使用this uncompressed jVectorMap(複製,粘貼並將其保存在文件中,並用它來代替當前正在使用的縮小的jVectorMap)並查看導致該問題的線。

+0

感謝您的幫助!給我這個問題的線是524,說==> if(!jvm.WorldMap.maps [this.params.map])拋出新的錯誤(「嘗試使用未加載的映射:」+ this.params。地圖);在android <4.0上導致此問題的原因是什麼? – Jason

+0

我不認爲它與android或jvectormap有任何關係。很可能您沒有鏈接到正確的地圖,例如jquery-jvectormap-us-aea-en.js必須具有映射:'us_aea_en'或jquery-jvectormap-fr-merc-en.js必須具有映射:'fr_merc_en'。 – itmitica

+0

適用於Android 4.0和iOS。但在Android <4.0只適用於非Android默認瀏覽器(例如:Firefox) – Jason