0

J'ai créé une application Google Maps qui montre le portefeuille d'une entreprise. La chose étrange est que mes marqueurs ne sont pas visibles dans ie8. Est-ce que quelqu'un a une solution? c'est le code javascript.Les marqueurs ne sont pas affichés dans 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); 

Répondre

0

J'ai essayé de reproduire votre problème et j'ai écrit le code html suivant, mais le marqueur est affiché dans IE8. Donc je suppose que votre code posté ici manque ce qui est (peut-être) mauvais avec le vôtre.

<!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

Je l'ai rafraîchi, et cela a fonctionné d'une certaine façon. Je pense que c'est juste un petit buggy, merci quand même! – luukgruijs

Questions connexes