-1

我編寫了一個JavaScript來初始化Google Map。代碼在使用Firefox瀏覽器時工作得很好。我已經嘗試過Firebug來發現錯誤。 Firebug說代碼很好。但是,如果我想在Internet Explorer中運行腳本,則完全相同的代碼不起作用。所以我想這肯定是IE的一個問題。只要點擊KML圖層或者通過激活單選按鈕突出顯示特定區域,該腳本就會中斷。谷歌地圖腳本Internet Explorer的錯誤

這裏是我的初始化函數:

function initialize(){ 

map = new google.maps.Map(document.getElementById("googleMap"),mapProp); 


var layer = new google.maps.FusionTablesLayer({ 
    query: { 
     select: 'geometry', 
     from: 'XXXX' 
    }, 

     styles: [{ 
     polygonOptions: { 
     fillColor: '#00FF00', 
     fillOpacity: 0.01, 
     strokeOpacity: 0.01} 
    },{ 
    // Objects from the array positive should be colored in a diffrent color 
    where: 'OBJECTID IN (' +pos +positive[positive.length-1].ID +')', 
     polygonOptions: { 
     fillColor: '#00FF00' 
     } 

    },{ 
      where: 'OBJECTID IN (' +pos +positive[positive.length-1].ID +')', 
     polygonOptions: { 
     fillOpacity: 0.5 
     } 
    },{ 

    where: 'OBJECTID IN (' +neg +negative[negative.length-1].ID +')', 
     polygonOptions: { 
     fillColor: '#FF0000' 
     } 

    }, { 
      where: 'OBJECTID IN (' +neg +negative[negative.length-1].ID +')', 
     polygonOptions: { 
     fillOpacity: 0.3 
     } 
}] 
    }); 

google.maps.event.addListener(layer, 'click', function(event) { 
     var msg = event.infoWindowHtml.toString(); 
     var countryName = msg.substr(parseInt(msg.indexOf('Name')), parseInt(msg.indexOf('geometry'))); 
     var CC = event.row['CC'].value 

    for (i = 0; i <countries.length-1; i++){ 
     var CChilf = countries[i].CC; 
      if (CChilf == CC){ 
      msg = countries[i].Name + "<br> Balance: " + countries[i].balance; 
      } 
      else msg = countries[i].Name; 
     } 

     // Change the content of the InfoWindow 
     event.infoWindowHtml = msg; 

     }); 

layer.setMap(map);  
} 

這裏是我的頭:

<link href="/apis/fusiontables/docs/samples/style/default.css" 
    rel="stylesheet" type="text/css"> 
<script type="text/javascript" 
    src="http://maps.google.com/maps/api/js?sensor=false"></script> 

<script type="text/javascript"> 

感謝很多提前:)

+1

你提了)錯誤是什麼,B)你在你的蒸汽機車運行的是什麼版本的Internet雷管的? –

+1

您在控制檯中收到的錯誤是什麼? – Joyson

+0

對不起。這是我第一次在像stackoverflow這樣的頁面上尋求建議。 A)沒有真正的錯誤消息,它更多的警告消息: Google Maps API警告:NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys但我可以不明白爲什麼它適用於Firefox,但不適用於IE。 B)Internet Explorer版本爲8.我知道這個版本很低,但不能更改版本。 – Nils

回答

0

IE 8 is no longer supported for the Google Maps Javascript API v3

the release notes

Internet Explorer 8中支持結束八月

31 2015年

隨着2015年8月31日的,Internet Explorer 8中不再通過谷歌地圖的JavaScript API正式支持。請參閱supported browsers的列表。有關Microsoft瀏覽器支持政策的信息,請參閱IEBlog post of August 7, 2014

note that IE 9 isn't supported anymore either

+0

感謝您的提示。 IE版本之外的主要問題是,IE中的Google地圖不支持兼容性視圖。 – Nils