2012-04-11 57 views
3

我剛開始使用谷歌地圖API。 當我打開頁面時,它總是給我提供相同的錯誤消息, ,它說 「資源解釋爲圖像,但使用MIME類型text/html傳輸」。 並且在頁面上看不到任何東西。谷歌地圖API響應錯誤消息「資源解釋爲圖像,但與MIME類型文本/ HTML傳輸」

我完全不知道如何弄清楚什麼是錯的。 我粘貼下面的代碼。感謝您的幫助。

----------我的代碼從這裏-------------------------------- ------------

<!DOCTYPE html> 
<html lang="ja"> 
<head> 
<meta charaset="utf-8"> 
<title>Googlemap</title> 
<script src="http://maps.google.com/maps/api/js?sensor=true&language=ja"></script> 
<style> 
    #map { 
      width: 100%; 
      height: 100%; 
      } 
</style> 
</head> 
<body> 
<div id="map"></div> 
<script> 
    var latlng = new google.maps.LatLng(35.66, 139.69); 
    var options = { 
     zoom: 15, 
     center: latlng, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 
    var map = new google.maps.Map(document.getElementById('map'), options); 
</script> 

</body> 
</html> 

----------我的代碼,直到這裏----------------- ---------------------------

回答

0

您正在爲map DIV分配相對寬度和高度,但您還需要爲父元素(即html和body)分配絕對或相對的寬度和高度。

例子:

html, body, #map { 
    width: 100%; 
    height: 100%; 
} 
相關問題