<?php
	define('DIRCMS_ROOT', str_replace("\\", '/',substr(dirname(__FILE__),0,-3)));
	require DIRCMS_ROOT.'/include/common.inc.php';
	require DIRCMS_ROOT.'/include/admin/global.func.php';
	$action=empty($action)?'files':trim($action);
	switch($action)
	{
		case 'distancepole':
			if(intval($x*$y) && is_numeric($x) && is_numeric($y))
			{
				echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>标注到地图 - Powered by Dircms</title> 
<script src="'.DIRCMS_PATH.'images/js/jquery.min.js"></script>
<script language="javascript" src=" http://api.51ditu.com/js/maps.js "></script>
</head>

<body>
<div id="myMap" style="position:relative; width:600px; height:500px;"></div>

<script language="javascript">
	var maps = new LTMaps( "myMap" );
	maps. centerAndZoom ( new LTPoint( '.$x.', '.$y.' ) , 3 );
	var control = new LTStandMapControl();
	maps.addControl( control );  // 缩放工具条
	var control = new LTZoomInControl();
	maps.addControl( control );  //拉框放大控件
	var control = new LTMarkControl(); //标注控件
	maps.addControl( control );
	var marker1 = new LTMarker( new LTPoint( '.$x.', '.$y.' ) );
	maps.addOverLay( marker1 );
	function getPoi(){
	var poi = control.getMarkControlPoint();
	var y=poi.getLatitude();
	var x=poi.getLongitude();
	$(window.opener.document).find("form[@name=\'myform\'] #'.$id.'").val(x+","+y);
	alert("标注成功！");
	window.close();
}
LTEvent.addListener( control , "mouseup" , getPoi );
</script>
</body>
</html>
';
			}
			else
			{
				echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>标注到地图 - Powered by Dircms</title> 
<script src="'.DIRCMS_PATH.'images/js/jquery.min.js"></script>
<script language="javascript" src=" http://api.51ditu.com/js/maps.js "></script>
</head>

<body>
<div id="myMap" style="position:relative; width:600px; height:500px;"></div>

<script language="javascript">
	var maps = new LTMaps( "myMap" );
	maps. centerAndZoom ( new LTPoint( '.MAP.' ) , 4 ); //地图定位
	var control = new LTStandMapControl();
	maps.addControl( control );  // 缩放工具条
	var control = new LTZoomInControl();
	maps.addControl( control );  //拉框放大控件
	var control = new LTMarkControl(); //标注控件
	maps.addControl( control );
	function getPoi(){
	var poi = control.getMarkControlPoint();
	var y=poi.getLatitude();
	var x=poi.getLongitude();
	$(window.opener.document).find("form[@name=\'myform\'] #'.$id.'").val(x+","+y);
	alert("标注成功！");
	window.close();
}
LTEvent.addListener( control , "mouseup" , getPoi );
</script>
</body>
</html>
';
			}
			exit();
			break;
		default:
			exit('Bad request!');
			break;
	}
?>