google地图简单示例

要先获取Google地图的API 密钥:http://code.google.com/intl/zh-CN/apis/maps/signup.html

Google提供的开发文档很多

我的代码如下

Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    
<title>Untitled Page</title>
    
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAfhiBJ2VvezGxWN5QTnJF1hRiMmuTicfa9ZYrooSj9awNojOYohQ2gsd6YmWEocGuZPza89ghBvNpWw" type="text/javascript"></script>
<script type="text/javascript">    
function initialize() {      
if (GBrowserIsCompatible()) {        
        
var map = new GMap2(document.getElementById("map_canvas"));  
        map.setMapType(G_SATELLITE_MAP);
        
var point = new GLatLng(30.27697,120.127296);
        map.setCenter(point, 
17); 
        
var marker = new GMarker(point);
        GEvent.addListener(marker,
"click"function() {
            map.openInfoWindow(point,
"<b>东方通信大厦!<br />我就在这上班</b>");
          });
        map.addOverlay(marker);
    }
}    
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style=" 500px; height: 300px"></div>
</body>
</html>
原文地址:https://www.cnblogs.com/liulun/p/1606562.html