2012-01-13 49 views
0

我正在使用谷歌地圖API。谷歌地圖標記不在IE中加載

以下是在<head>

<script src="http://maps.google.com/maps/api/js?sensor=false"></script> 

以下是在body

<script type="text/javascript"> 

    var infowindow = new google.maps.InfoWindow({ 
     //size: new google.maps.Size(150,150) 
     maxWidth: 500, 
    }); 
    function initialize() { 
     var myOptions = { 
      zoom: 4, 
      center: new google.maps.LatLng(38.90, -99.00), 
      mapTypeControl: true, 
      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}, 
      navigationControl: true, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     } 

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

     var markers = []; 


     for (var i = 0; i < businesses.length; i++) { 

      var latLng = new google.maps.LatLng(businesses[i].latitude, businesses[i].longitude); 
      var marker = createMarker(latLng,businesses[i].name, businesses[i].description); 

      markers.push(marker); 


     } 

    } 

    function createMarker(latlng, name, html) { 
     var contentString = html; 
     var marker = new google.maps.Marker({ 
      position: latlng, 
      map: map, 
      zIndex: Math.round(latlng.lat()*-100000)<<5 
      }); 

     google.maps.event.addListener(marker, 'click', function() { 
      infowindow.setContent(contentString); 
      infowindow.open(map,marker); 
     }); 
    } 


</script> 
<script type="text/javascript"> 
    var businesses = new Array(); 
</script> 

我然後運行一些PHP和PHP foreach語句

<script type="text/javascript"> 
    business = { 
     name:"<?php echo $i; ?> - Columbia Gorge Blue Grass", 
     description:"<?php echo $row['display_name']; ?>", 
     address:"$row['address'];", 
     latitude:"<?php echo $row['lat']; ?>", 
     longitude:"<?php echo $row['lon']; ?>", 
     url:"$row['url'];", 
     business_type:"Getaway" 
    }; 
    businesses[<?php echo $i; ?>] = business; 
</script> 

內有這樣的在foreach聲明之後,我有div地圖和調用初始化語句

<div id="map-container"><div id="map"></div></div> 
<script>  
    initialize();  
</script> 

一切正常鰭在Chrome和Firefox,但在IE中,我得到了「完成,但網頁上有錯誤。」錯誤。地圖在IE中加載正常,但地圖上沒有標記。

當我點擊IE錯誤圖標,這是我的消息得到: 網頁錯誤的詳細信息

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8; InfoPath.3) 
Timestamp: Fri, 13 Jan 2012 16:54:36 UTC 


Message: Object doesn't support this property or method 
Line: 111102061 
Char: 3 
Code: 0 
URI: http://www.domain.com/contractor/listings 

我敢肯定,當initialize();被稱爲出現問題,但我不能告訴是什麼導致了這個問題。

任何幫助或見解,將不勝感激。

感謝

-Mike

回答

1

這裏尾隨逗號:

maxWidth: 500, 
+0

沒有解決它。謝謝你的提示。 – bigmike7801 2012-01-13 17:42:48

+0

@ bigmike7801:檢查了你的Css屬性? – ArunRaj 2014-04-03 04:14:47

0

只是一個想法。經度和緯度都是浮點數。不確定在這種情況下是否應該將它們包裝在「」中。

latitude:"<?php echo $row['lat']; ?>", 
longitude:"<?php echo $row['lon']; ?>", 

可能IE將它們視爲字符串。另一個建議;刪除此行,看看是否有任何區別:

zIndex: Math.round(latlng.lat()*-100000)<<5