<!--#include file="../conn.asp"-->
<!--#include file="../ks_cls/kesion.commoncls.asp"-->
<%
dim MapKey,MapCenterPoint
dim ks:set ks=new publiccls
mapKey=KS.Setting(175)
MapCenterPoint=KS.Setting(176)
If KS.IsNul(MapCenterPoint) Then MapCenterPoint="39.961233,116.324439"
set ks=nothing
%>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>电子地图标注</title>
<style type="text/css">
 body{font-size:12px;}
</style>
<script src="http://ditu.google.com/maps?file=api&amp;v=2&amp;key=<%=MapKey%>"
  type="text/javascript"></script>

              
<script language="javascript">
var map;

function load(){
	if (GBrowserIsCompatible()) {
	   map = new GMap2(document.getElementById('map'));
	  showLocation();
	 }
	}
   

   function bj(){
	   map.clearOverlays();
	   var ico = new GIcon(G_DEFAULT_ICON);
	   ico.iconSize = new GSize(32, 32);
	   var markobj = new GMarker(new GLatLng(map.getCenter().lat(),map.getCenter().lng()),{draggable: true,icon: ico });
	   map.addOverlay(markobj);
	   document.getElementById('point').innerHTML='纬度/经度: ' +markobj.getPoint().lat() + ',' +  markobj.getPoint().lng();
	   window.parent.document.getElementById('MapMark').value=markobj.getPoint().lat() + ',' +  markobj.getPoint().lng();
	   
	  GEvent.addListener(markobj, "click", function() {
                  markobj.openInfoWindowHtml('<br>'+'纬度/经度: ' + markobj.getPoint().lat() + 
                    ', ' +  markobj.getPoint().lng()); 
                });
				
	  GEvent.addListener(markobj,"drag",function(){
		  document.getElementById('point').innerHTML='纬度/经度: ' +markobj.getPoint().lat() + ',' +  markobj.getPoint().lng();
		  window.parent.document.getElementById('MapMark').value=markobj.getPoint().lat() + ',' +  markobj.getPoint().lng();
		  });	
	  	  
	  GEvent.addListener(markobj,"dragend",function(){
		  var point = markobj.getPoint();
				      map.panTo(point);
		  document.getElementById('point').innerHTML='纬度/经度: ' +markobj.getPoint().lat() + ',' +  markobj.getPoint().lng();
		  window.parent.document.getElementById('MapMark').value=markobj.getPoint().lat() + ',' +  markobj.getPoint().lng();
		  });	  
		  
		  
	//-------------拖动地图后重新建立标注-----------	  
	  GEvent.addListener(map,"moveend",function(){
		        map.clearOverlays();
			    var center = map.getCenter();
				var ico = new GIcon(G_DEFAULT_ICON);
				ico.iconSize = new GSize(32, 32);
				var markobj1 = new GMarker(center, {draggable: true,icon: ico});
				map.addOverlay(markobj1);
		  document.getElementById('point').innerHTML='纬度/经度: ' +markobj1.getPoint().lat() + ',' +  markobj1.getPoint().lng();
		  window.parent.document.getElementById('MapMark').value=markobj1.getPoint().lat() + ',' +  markobj1.getPoint().lng();
		  
		   GEvent.addListener(markobj1,"drag",function(){
		  document.getElementById('point').innerHTML='纬度/经度: ' +markobj1.getPoint().lat() + ',' +  markobj1.getPoint().lng();
		  window.parent.document.getElementById('MapMark').value=markobj1.getPoint().lat() + ',' +  markobj1.getPoint().lng();
		  });	
		  
		  
		  GEvent.addListener(markobj1,"dragend",function(){
			   var point = markobj1.getPoint();
				      map.panTo(point);
		  document.getElementById('point').innerHTML='纬度/经度: ' +markobj1.getPoint().lat() + ',' +  markobj1.getPoint().lng();
		  window.parent.document.getElementById('MapMark').value=markobj1.getPoint().lat() + ',' +  markobj1.getPoint().lng();
		  });	
		  
		  GEvent.addListener(markobj1, "click", function() {
                  markobj1.openInfoWindowHtml('<br>'+'纬度/经度: ' + markobj1.getPoint().lat() + 
                    ', ' +  markobj1.getPoint().lng()); 
                });
		  
		  });	
		  
	  	    
		  
	   }
	   
            var geocoder = null;
	         
			var status=[];
			status[G_GEO_SUCCESS]            = "Success";
			status[G_GEO_MISSING_ADDRESS]    = "Missing Address";
			status[G_GEO_UNKNOWN_ADDRESS]    = "Unknown Address";
			status[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address";
			status[G_GEO_BAD_KEY]            = "Bad Key";
			status[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries";
			status[G_GEO_SERVER_ERROR]       = "Server Error"
	 
	
	
	
	 //-------------开始搜索--------------------
	function showLocation() {
				// 清除marker
				var mapControl = new GMapTypeControl(); 
                map.addControl(mapControl); 
                 map.addControl(new GLargeMapControl());
                map.addControl(new GMapTypeControl());
	            var mini = new GOverviewMapControl(new GSize(100,100));
	           map.addControl(mini);
			   
				geocoder = new GClientGeocoder();
				map.clearOverlays();
				
				var address ='北京市';
					
				geocoder.getLocations(address, cb_showLocation);
			} 
	
	
	function cb_showLocation(result) {
				// 显示结果
				if (result.Status.code == G_GEO_SUCCESS)  {
					// 成功表明
					for (var i=0; i<result.Placemark.length; i++) {
						var lat = result.Placemark[i].Point.coordinates[1]; // lat
						var lng = result.Placemark[i].Point.coordinates[0]; // lng
						var address = result.Placemark[i].address; // 地址
						var point = new GLatLng(lat,lng);
			            
						var marker=new GMarker(point, {title:i+1});;
						//map.addOverlay(marker);
						map.setCenter(new GLatLng(<%=MapCenterPoint%>), 10);
						 var point = marker.getPoint();
				          map.panTo(point);
						  document.getElementById('point').innerHTML='纬度/经度: ' +marker.getPoint().lat() + ',' +  marker.getPoint().lng();
		                  window.parent.document.getElementById('MapMark').value=marker.getPoint().lat() + ',' +  marker.getPoint().lng(); 
						  
					} // for
				} // if

			}


</script>

</head>
<body onload="load()">
<div id="map" style="width: 742px; height: 350px; font-size:12px"></div>

<br /><input type="text" id="txtAddress" name="txtAddress" /><input type="button" value="查询" onClick="showLocation();" />
<img src="images/zuobiaozu.gif"  onclick="javascript:bj()"/>&nbsp;&nbsp;<img src="images/ok.gif"  onclick="javascript:parent.closeWindow()"/>
<div id="point"></div>
<div id="divOutput" ></div>

</body>
</html>
