IE8中使用Google Maps的错误“未定义为null或不是对象”

问题描述

| 我在这里创建了一个示例来显示问题。 http://bit.ly/j2nb1k 代码是js,因此您可以完整查看。在包括IE9在内的任何现代浏览器中,它都能正常工作。但是,如果您在IE8或更低版本中加载它,则会遇到一个令人讨厌的“未定义为null或不是对象”。 我在这里想念什么? 资料来源...
var map;
  function initialize() {

    var latlng = new google.maps.LatLng(51,-1);
    var myOptions = {
      zoom: 2,center: latlng,mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById(\"map_canvas\"),myOptions);

   vaacinit();
  }

function vaacinit() {  
  var FL150 = [new google.maps.LatLng(-43.568055555556,75.833333333333),new google.maps.LatLng(-59.384722222222,74.734722222222),new google.maps.LatLng(-64.668055555556,88.25),new google.maps.LatLng(-65.901388888889,133.58472222222),new google.maps.LatLng(-59.35,131.23333333333),new google.maps.LatLng(-55.918055555556,92.368055555556),new google.maps.LatLng(-43.568055555556,];drawpoly(FL150,\'#848484\');
var FL200 = [new google.maps.LatLng(-54.7,90.533333333333),new google.maps.LatLng(-60,158.23472222222),new google.maps.LatLng(-59.333333333333,160.00138888889),new google.maps.LatLng(-34.684722222222,160.58472222222),new google.maps.LatLng(-40.5,150.5),new google.maps.LatLng(-40.518055555556,145.86805555556),new google.maps.LatLng(-38.2,144.7),new google.maps.LatLng(-37,139.35),new google.maps.LatLng(-35.85,129.33333333333),new google.maps.LatLng(-39.333333333333,117.03472222222),new google.maps.LatLng(-38.233333333333,110.06666666667),new google.maps.LatLng(-29.418055555556,104.73333333333),new google.maps.LatLng(-30.551388888889,90.501388888889),new google.maps.LatLng(-54.7,];drawpoly(FL200,\'#848484\');
var well = [new google.maps.LatLng(-34.666666666667,160),new google.maps.LatLng(-34.666666666667,172.38333333333),new google.maps.LatLng(-40.568055555556,-160),new google.maps.LatLng(-50.518055555556,-140.56805555556),new google.maps.LatLng(-61.216666666667,-119.35138888889),new google.maps.LatLng(-71.166666666667,-128.23472222222),new google.maps.LatLng(-70.55,-150),new google.maps.LatLng(-52.401388888889,-177.01805555556),];drawpoly(well,\'#848484\');   





 }


function drawpoly(polyCoords,passedColor){

 var thispoly;
 var thispolyCoords = polyCoords;

 thispoly = new google.maps.polygon({
    paths: thispolyCoords,strokeColor: passedColor,strokeOpacity: 0.8,strokeWeight: 2,fillColor: passedColor,fillOpacity: 0.35
  });

  thispoly.setMap(this.map);

 }
    

解决方法

        您的数组以逗号结尾-无效,并且会抛出IE版本 例如,比较:
var notValidArray = [1,2,3,];
var validArray = [1,3];