我是javascript的初学者,我正在尝试在浏览器中加载一个简单的Google地图(firefox)。但是,地图不会加载。
以下是我的HTML:
<!doctype html>
<html>
<head>
<title>Can you guess the Country?</title>
<meta charset="utf-8">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key={MY_API_KEY}&sensor=true"></script>
<script src="mapGame.js"></script>
</head>
<body>
<div id="map">
</div>
</body>
</html>
以下是链接的mapGame.js:
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
非常感谢任何帮助!
答案 0 :(得分:0)
可能与div#map
的高度有关,地图就在那里,但你只是看不到它。
<head>
<style>
#map {
height:500px;
}
</style>
</head>