<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://ditu.google.cn/maps?file=api&v=2&key=&sensor=true" type="text/javascript"></script>
<script type="text/javascript">
function initialize()
{
if (GBrowserIsCompatible())
{
var map = new Map2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(39.9493, 116.3975), 13);
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://ditu.google.cn/maps?file=api&v=2&key=&sensor=true" type="text/javascript"></script>
<script type="text/javascript">
function initialize()
{
if (GBrowserIsCompatible())
{
var map = new Map2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(39.9493, 116.3975), 13);
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>
var width;
var map;
var $ = function(Id){return document.getElementById(Id);}
function init()
{
height = document.documentElement.clientHeight;
width = document.documentElement.clientWidth;
$("divMap").style.width=width-10;
$("divMap").style.height=height-10;
initialize();
}
function initialize()
{
if (GBrowserIsCompatible())
{
map = new GMap2($("divMap"));
map.setCenter(new GLatLng(39.96323,116.30355), 16);
//map.addMapType(G_SATELLITE_3D_MAP); map.addControl(new GHierarchicalMapTypeControl());
map.addControl(new GLargeMapControl3D());
//鼠标滚轮 放大、缩小地图
map.enableScrollWheelZoom();
}
}
function ReMapSize()
{
height = document.documentElement.clientHeight;
width = document.documentElement.clientWidth;
$("divMap").style.width=width;
$("divMap").style.height=height-25;
}
window.onload=init;
window.onresize=ReMapSize;
你运行之后看看源代码 key那里有没有东西 没有的话 就是<%%>这里出错了
但是要发布到服务器上 就得写正确的网址了