首先至http://code.google.com/intl/zh-CN/apis/maps/signup.html注册得到使用地图的key
页面上使用代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=true_or_false&key=你的Key" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(39.9493, 116.3975), 13);
}
}
</script>
</head>
<body οnlοad="initialize()" οnunlοad="GUnload()">
<form id="form1" runat="server">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</form>
</body>
</html>
示例效果: