0

我創建了一個顯示公司投資組合的Google地圖應用程序。奇怪的是我的標記只在ie8中沒有顯示。有沒有人有解決方案?這是javascript代碼。未在ie中顯示的標記8

var map; 
    function initialize() { 
     var myOptions = { 
     zoom: 6, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 

[arrays with data] 

var infoWindow = new google.maps.InfoWindow; 
    map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); 

    // Set the center of the map 
    var pos = new google.maps.LatLng(50.941641437268906, 9.088932512500037); 
    map.setCenter(pos); 
    function infoCallback(infowindow, marker) { 
     return function() { 
     infowindow.open(map, marker); 
    }; 





function setMarkers(map, all) { 
for (var i in all) { 
var adres    = all[i][0]; 
var name    = all[i][1];           
var property   = all[i][2]; 
var office    = all[i][3]; 
var warehouse   = all[i][4]; 
var other    = all[i][5]; 
var total    = all[i][6]; 
var parkingspaces    = all[i][7]; 
var yearOfConstruction   = all[i][8]; 
var lat     = all[i][9]; 
var lng     = all[i][10]; 
var latlngset; 
latlngset = new google.maps.LatLng(lat, lng); 
var marker = new google.maps.Marker({ 
map: map, title: adres, position: latlngset, icon: image 
     }); 


     var image = 'images/pandklein.png'; 
     var content = '<div id=content>' +'<img class="thumpnail" src="thumpnail/' + name + '.png" alt ="' + name + '">' + '<div class="map-content"><h3 class="title">' + adres + '</h3>' + 
     'Lettable floor area (m&#178;):' + "<p class='tekst'>" + total + "</p>" + '<br />' + 'Property:' + ' ' + "<p class='tekst'>" + property + "</p>" + 
      '<br />' + 'Year of construction:' + ' ' + "<p class='tekst'>" + yearOfConstruction + "</p>" + '</div>';    
     var infowindow = new google.maps.InfoWindow(); 
      infowindow.setContent(content); 
      google.maps.event.addListener(
      marker, 
      'click', 
      infoCallback(infowindow, marker) 
     ); 
     } 
    }   
    // Set all markers in the all variable 
    setMarkers(map, all); 
    }; 
    // Initializes the Google Map 
    google.maps.event.addDomListener(window, 'load', initialize); 

回答

0

我試圖重現您的問題,並寫下如下html,但標記顯示在IE8中。所以我假設你在這裏發佈的代碼缺少你的(可能)錯誤。

<!DOCTYPE html> 
<html> 
<head> 
<script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript" charset="UTF-8"></script> 
</head> 
<body> 
<div id="map_canvas" style="width:400px;height:400px;"> 
</div> 
<script type="text/javascript"> 
var map; 
function initialize() { 
    var myOptions = { 
     zoom: 6, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 

    var infoWindow = new google.maps.InfoWindow; 
    map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); 

    // Set the center of the map 
    var pos = new google.maps.LatLng(50.941641437268906, 9.088932512500037); 
    map.setCenter(pos); 

    function infoCallback(infowindow, marker) { 
     return function() { 
      infowindow.open(map, marker); 
     }; 
    } 

    function setMarkers(map, all) { 
     for (var i in all) { 
      var adres    = all[i][0]; 
      var name    = all[i][1]; 
      var property   = all[i][2]; 
      var office    = all[i][3]; 
      var warehouse   = all[i][4]; 
      var other    = all[i][5]; 
      var total    = all[i][6]; 
      var parkingspaces  = all[i][7]; 
      var yearOfConstruction = all[i][8]; 
      var lat     = all[i][9]; 
      var lng     = all[i][10]; 
      var latlngset; 

      latlngset = new google.maps.LatLng(lat, lng); 
      var marker = new google.maps.Marker({map: map, title: adres, position: latlngset}); //icon: image}); 
      //var image = 'images/pandklein.png'; // why declared here? 
      var content = '<div id=content>' +'<img class="thumpnail" src="thumpnail/' + name + '.png" alt ="' + name + '">' + '<div class="map-content"><h3 class="title">' + adres + '</h3>' + 
      'Lettable floor area (m&#178;):' + "<p class='tekst'>" + total + "</p>" + '<br />' + 'Property:' + ' ' + "<p class='tekst'>" + property + "</p>" + 
      '<br />' + 'Year of construction:' + ' ' + "<p class='tekst'>" + yearOfConstruction + "</p>" + '</div>'; 
      var infowindow = new google.maps.InfoWindow(); 
      infowindow.setContent(content); 
      google.maps.event.addListener(marker, 'click', infoCallback(infowindow, marker)); 
     } 
    }   

    var all = [["", "", "", "", "", "", "", "", "", 51, 9]];  

    // Set all markers in the all variable 
    setMarkers(map, all); 
} 

// Initializes the Google Map 
google.maps.event.addDomListener(window, 'load', initialize()); 
</script> 
</body> 
</html> 
+0

我刷新它,它以某種方式工作。我認爲它只是一輛小馬車,謝謝! – luukgruijs