我刚开始使用 googlemaps 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>
------------我的代码到这里-------------------------------- ----------
最佳答案
您正在为 map
DIV 分配相对宽度和高度,但您还需要为父元素(即 html 和 body)分配绝对或相对宽度和高度。
例子:
html, body, #map {
width: 100%;
height: 100%;
}
关于api - google maps api 响应错误消息 "Resource interpreted as Image but transferred with MIME type text/html",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10098929/