开发者

'var' is null or not an object

The code works fine in Firefox, but not in IE8. I'm getting an erro开发者_开发技巧r: 'address' is null or not an object.

Have been googling for days and couldn't get a clear answer on how to fix/debug this. Hope stackoverflow.com can help.

var latlng = [
      {
address: new GLatLng(-6.1364941,106.8000411),
marker0: myIcon0
},
      {
address: new GLatLng(-6.1364941,106.8000411),
marker0: myIcon0
},
      {
address: new GLatLng(1.3520831,103.8198361),
marker0: myIcon0
},
      {
address: new GLatLng(14.06666671,121.33333331),
marker0: myIcon
},
    ];
  var markers = []; 
  for ( var i = 0; i < latlng.length; i++ )
    {
      var marker = new GMarker( latlng[ i ].address, latlng[ i ].marker0 );
      map.addOverlay( marker );
      markers[i] = marker;
    }
    $(markers).each(function(i,marker){ 
      GEvent.addListener(marker,"click", function(){ 
        // map.panTo(marker.getLatLng());
        map.setCenter(marker.getLatLng(), 10);
        marker.openInfoWindowHtml($('.view-display-id-attachment_1 .views-row-'+(i+1)).html(), {maxWidth:200});
      });
      $("<li />") 
        .html($('.view-display-id-attachment_1 .views-row-'+(i+1)).html()) 
        .click(function(){ 
          map.setCenter(marker.getLatLng(), 10);
          marker.openInfoWindowHtml($('.view-display-id-attachment_1 .views-row-'+(i+1)).html(), {maxWidth:200}); // custom balloon text
          // alert($('.view-display-id-attachment_1 .views-row-'+(i+1)).html()); // VIEWS ROW COUNT DEBUG
        }) 
        .appendTo("#wtb-list");
    });


The issue is here:

marker0: myIcon
},  //<-- here!
    ];

that trailing comma at the end of your array declaration will give IE8 issues, remove it :) Other browsers..."overlook?" this in most cases, IE will always error on them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜