<!DOCTYPE  html>
<html>
<?php echo $this->fetch('head.html'); ?>
<body>
	<div class="tabs-border">
		<a href="?m=sites" class="item">校园列表</a>
		<a href="?m=sites&a=add" class="item active">添加校园</a>
	</div>
	<div class="main-body">

<form method="post" action="<?php echo $this->_var['appadmin']; ?>?m=sites&a=save">
<input type="hidden" name="siteid" value="<?php echo $this->_var['data']['siteid']; ?>" />
<table class="table-add">
  <tr>
    <td >名称：</td>
    <td ><input name="sitename" type="text" id="sitename" value="<?php echo $this->_var['data']['sitename']; ?>" /></td>
  </tr>
   
  
  
  
  <tr>
    <td>状态：</td>
    <td><input type="radio" name="is_open" id="radio" value="1" <?php if ($this->_var['data']['is_open'] == 1): ?> checked="checked"<?php endif; ?> />
      开通
        <input type="radio" name="is_open" id="radio2" value="2" <?php if ($this->_var['data']['is_open'] == 2): ?> checked="checked"<?php endif; ?> />
     关闭
			</td>
  </tr>
  
 
  <tr>
  	<td>Gps</td>
    <td>
    地图搜索：<input type="text" class="w100" name="word" id="word" /> <br>
    <div id="map_canvas" style="width:600px; height:300px;"></div>
    </td>
  </tr>
   <tr>
          <td>纬度：</td>
          <td><input type='text' name='lat' id='lat' value='<?php echo $this->_var['data']['lat']; ?>' ></td>
        </tr>
        <tr>
          <td>精度：</td>
          <td><input type='text' name='lng' id='lng' value='<?php echo $this->_var['data']['lng']; ?>' ></td>
        </tr>
 
  
</table>
<div class="btn-row-submit js-submit">保存</div>
</form>
 
<?php echo $this->fetch('footer.html'); ?>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=<?php echo BDMAPKEY; ?>"></script>
    <script language="javascript">
	function NoSubmit(ev)
	{
		if( ev.keyCode == 13 )
		{
			return false;
		}
		return true;
	}
	$("#word").bind("keyup",function(){
			localsearch($(this).val());
		});
   var map = new BMap.Map("map_canvas");
   map.enableScrollWheelZoom();
   var point = new BMap.Point(<?php if ($this->_var['data']['lat'] > 0): ?><?php echo $this->_var['data']['lng']; ?>,<?php echo $this->_var['data']['lat']; ?><?php else: ?>118.165810,24.485228<?php endif; ?>);
   map.centerAndZoom(point, 12);
   var marker = new BMap.Marker(point);  // 创建标注
	map.addOverlay(marker);              // 将标注添加到地图中
	marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
   map.addEventListener("click", function(e){
	   map.removeOverlay(marker);
	   point = new BMap.Point(e.point.lng,e.point.lat);
	   marker = new BMap.Marker(point);  // 创建标注
	   
		map.addOverlay(marker);  
	   $("#lat").val(e.point.lat);
	   $("#lng").val(e.point.lng);
   });
   
   function localsearch(word){
	   var local = new BMap.LocalSearch(map, {
		  renderOptions:{map: map}
		});
		local.search(word);
   }
    </script>