<!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://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAFyNkisYpeRApb9npqu1QbxScVgSXaHJtFRozQ183btHSsuF5pRTUynHMVcZVwduTbRoM78UAqfZs2g" type="text/javascript"></script>

</head>
<body onload="window.setTimeout('initialize()',1200)" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
<script type="text/javascript">   
var map = null;
var geocoder = null;
 
function initialize() {     
 if (GBrowserIsCompatible()) {     
  map = new GMap2(document.getElementById("map_canvas"));
    
 map.setCenter(new GLatLng(39.9493, 116.3975), 13);
   
  // map.setCenter(new GLatLng(39.9410345535317, 116.31178379058838),14);
 geocoder = new GClientGeocoder();
 alert(geocoder);
  showAddress("北京市海淀区紫竹院路62号院赛迪大厦1号楼10层2101室");  
 }    
}   

  function showAddress(address) {
  if (geocoder) {
  geocoder.getLatLng(
  address,
  function(point) {
  if (!point) {
  alert("不能解析: " + address);
  } else {
  map.setCenter(point, 17);
//map.openInfoWindow(map.getCenter(),document.createTextNode("Hello, world"));
  var marker = new GMarker(point);
 map.addOverlay(marker);
marker.openInfoWindowHtml(address);
  }
  }
  );
  }
  }

 </script>
</body>
</html>

posted on 2010-10-25 14:15 sanmao 阅读(263) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

常用链接

留言簿(5)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜