我使用的版本是3.8 沒有的一個關鍵。我在桌面之前(沒有鍵)使用了這個確切的代碼,它工作得很好,但現在由於某種原因,它不工作。
我找不到任何拼寫錯誤,導入聲明時沒有更改我使用的密鑰?
這裏是我的精簡代碼:
這個簡單的Google地圖代碼爲什麼不起作用?
<!DOCTYPE html>
<html>
<head>
<title>asdfasdf</title>
</head>
<body onload = "initialize();">
<!-- map here -->
<div id = "map"></div>
<!-- Google Maps API -->
<script type = "text/javascript" src = "http://maps.googleapis.com/maps/api/js?&sensor=true&v=3.8"></script>
<script type = "text/javascript">
function initialize()
{
// object literal for map options
var myOptions =
{
center: new google.maps.LatLng(37.09024, -95.712891), // coordinates for center of map 30, 3
zoom: 4, // smaller number --> zoom out
mapTypeId: google.maps.MapTypeId.HYBRID // ROADMAP, SATELLITE, TERRAIN, or HYBRID
};
// note: if the id has a dash in its' name, map instantiation doesn't work!
var map = new google.maps.Map(document.getElementById("map"), myOptions);
} // end of initialize
</script>
</body>
</html>
更改http://maps.googleapis.com/maps/api/js? & sensor = true & v = 3.8 to http://maps.googleapis.com/maps/api/js?&sensor=true&v=3.8 – Kotzilla