<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
    <%@include file="../../../../../frame/assets/header-all.jsp"%> 
    <link rel="stylesheet" type="text/css" href="../../../../resource/css/map.frame.css">
</head>
<body>
<body class="easyui-layout"  onselectstart="return false" >
    <div data-options="region:'center',split:false" class="easyui-layout"  style="border: none">
        <table id="jklk-tab-grid"></table>
    </div>  
   	<div id="jklk-contextMenu" class="easyui-menu" style="width:100px;display: none">   
		<div iconCls="icon-info-look" onclick="openWindow()">查看详情</div>
		<div iconCls="icon-location" onclick="locate();">地图定位</div> 
	</div> 
<script type="text/javascript">
var maingrid = null;

function getGrid (){
	return maingrid;
}

$(function(){
    initGrid();
})
//表格
function initGrid(){    
	maingrid = $('#jklk-tab-grid').datagrid({
        queryParams:'',
        rownumbers:true,
        columns : [[
			{field:'lkmc',title:'路口名称',width:250}
        ]],
        onRowContextMenu: function (e, rowIndex, rowData) {  
        	$('#jklk-tab-grid').datagrid('selectRow', rowIndex);
        	$('#jklk-contextMenu').menu('show', { 
        		left: e.pageX, 
        		top: e.pageY 
        		}); 
        	e.preventDefault();
        },
        onDblClickRow: function(index,row){
        	locate();
        }
    });
}
//加入所选，插入行数据
function addtGridData(record,clear){
	var grid = getGrid();
	var rows = grid.datagrid('getData').rows;
	if(grid){
		if(clear){
			grid.datagrid('loadData',{ total: 0, rows: [] });
		}
		if(rows.length != 0){
			for(var i = 0;i<rows.length;i++){
				if(rows[i] == record){
					$.showMsg("已加入所选！");
					return;
				}
			}
		}
		grid.datagrid('appendRow',record);
	}
	return;
}
//查看详情
function openWindow(){
	var records = $("#jklk-tab-grid").datagrid('getSelected');
 	windowid = top.$.createWin({
		 title	: 	'路口详情',
		 width  :  600,
		 height :  380,
		 data	:  records,
		 url	:  top.sysUrl+"/szmap/business/base/item/iframe/jklk-tab_show.jsp"
	 });
}
function loadData(data){
	maingrid.datagrid('loadData',data);
}

//地图定位
function locate(){
	var records = $("#jklk-tab-grid").datagrid('getSelected');
	parent.MapAPI.centerAtLatLngZoom(records.jd,records.wd,top.ditu.mapLevel );
	parent.MapMain.getLayer(parent.MapConst.LAYER_JKLK).locateMarker(records);
	console.log(records);
}
</script>
</body>
</html> 
