软测单独项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1681 lines
74 KiB

//开始获取接口
var timestamp1 = new Date().getTime();
var securityKey = 'RTcunWv#BVhi';
var signCar = sha1(timestamp1.toString() + securityKey);
var msgId = generateUUID();
var cluster, markers = [];
var carTraLineArr = [], carTraRouteInfo = [];
var _lttHTTPipUrl = "/lttGps";
layui.config({
base: '../../js/'
}).use(['layer', 'table', 'form', 'flow', 'laydate', 'element'], function () {
var $ = layui.jquery,
layer = parent.layer === undefined ? layui.layer : top.layer,
table = layui.table,
form = layui.form,
flow = layui.flow,
laydate = layui.laydate,
element = layui.element;
var OrgId = JSON.parse(window.sessionStorage.getItem("userInfo")).OrgID;
//根据当前登陆人机构ID获取机构所在经纬度
$.ajax({
type: "post",
url: "../../ashx/FireOrgHandler.ashx",
data: { Action: "getFireOrgName", ID: OrgId },
dataType: "json",
success: function (result) {
//alert(1);
console.log('获取机构信息');
console.log(result);
initMap(result.data.LON, result.data.LAT, result.data.CITY);
var myIcon = new AMap.Icon({ size: new AMap.Size(30, 40), image: '../../images/zgxf1.png', imageSize: new AMap.Size(30, 40) });
var marker = new AMap.Marker({
//position: new AMap.LngLat(94.40887, 29.580462),
position: new AMap.LngLat(result.data.LON, result.data.LAT),
title: result.data.ORG_NAME,
icon: myIcon,
zIndex:999
}); // 创建标注
marker.id = { ORG_ID: result.data.ORG_ID, ADDR: result.data.ADDR, ORG_NAME: result.data.ORG_NAME };
map.add(marker);
AMap.event.addListener(marker, 'click', function (e) {
var infoWindow = new AMap.InfoWindow({
content: "<div style='color: #0096ff;'>" + e.target.id.ORG_NAME + "</div>" //使用默认信息窗体框样式,显示信息内容
, offset: new AMap.Pixel(7, -30)
});
infoWindow.open(map, new AMap.LngLat(e.target.De.position.lng, e.target.De.position.lat));
})
initIco();
}
})
//配置各地图加载项图片
var IconConfig = {
SY: "../../images/trsy.png", //水源
Station: "../../images/xfz1.png", //消防站
XFS: "../../images/xfs1.png", //消防栓
Crane: "../../images/xfsk1.png",
WaterMT: "../../images/qsmt.png"
};
//坐标转换
//var convertor = new BMap.Convertor();
var pointArr = [], pointStateArr = [], carIcon = "";
//存储不同类型的点
var arr2 = [], arr3 = [], arr5 = [], arr6 = [], arr7 = [];
//存储不同类型的点图层
var labelsLayer_xhs = [], labelsLayer_xfsh = [], labelsLayer_trsy = [], labelsLayer_qsmt = [], labelsLayer_wxxfz = [];
function initIco() {
console.log("方法进入时间:" + new Date());
$.ajax({
type: "post",
url: "../../ashx/FireResource.ashx",
data: { Action: "GetWaterResource", type: "", OrgId: OrgId, random: new Date().getTime() },
dataType: "json",
success: function (result) {
console.log("数据返回前台:" + new Date());
//var data = eval("(" + result + ")");
data = result;
labelsLayer_xhs = new AMap.LabelsLayer({
zooms: [3, 20],
zIndex: 99,
// 该层内标注是否避让
collision: false,
// 设置 allowCollision:true,可以让标注避让用户的标注
allowCollision: true,
});
labelsLayer_xfsh = new AMap.LabelsLayer({ zooms: [3, 20], zIndex: 99, collision: false, allowCollision: true, });
labelsLayer_trsy = new AMap.LabelsLayer({ zooms: [3, 20], zIndex: 99, collision: false, allowCollision: true, });
labelsLayer_qsmt = new AMap.LabelsLayer({ zooms: [3, 20], zIndex: 99, collision: false, allowCollision: true, });
labelsLayer_wxxfz = new AMap.LabelsLayer({ zooms: [3, 20], zIndex: 99, collision: false, allowCollision: true, });
for (var index in data) {
if (data[index].LON != "" && data[index].LAT != "") {
if (data[index].LON != null && data[index].LON != "null" && data[index].LON != null && data[index].LON != "null" && data[index].LON != "NAN") {
var point;
switch (data[index].COORDINATE_TYPE) {
case "0":
try {
var gcj02 = wgs84togcj02(Number(data[index].LON), Number(data[index].LAT));
var x = gcj02[0];
var y = gcj02[1];
if (isNaN(x) || isNaN(y)) {
continue;
}
point = new AMap.LngLat(x, y);
} catch (ex) {
console.log(ex);
}
break;
default:
try {
point = new AMap.LngLat(data[index].LON, data[index].LAT);
} catch (exc) {
console.log(exc);
}
break;
}
var iconImg;
//1、水电站;2、取水码头;3、天然水源;4、消防水池;5、消防水鹤;6、消防栓;7、微型消防站;8、重点单位;
if (data[index].TYPE == "2") {//取水码头
iconImg = IconConfig.WaterMT;
}
else if (data[index].TYPE == "3") {//天然水源
iconImg = IconConfig.SY;
}
else if (data[index].TYPE == "5") {//消防水鹤
iconImg = IconConfig.Crane;
}
else if (data[index].TYPE == "6") {//消防栓
iconImg = IconConfig.XFS;
}
else if (data[index].TYPE == "7") {//微型消防站
iconImg = IconConfig.Station;
}
var icon = {
// 图标类型,现阶段只支持 image 类型
type: 'image',
// 图片 url
image: iconImg,
// 图片尺寸
size: [30, 30],
// 图片相对 position 的锚点,默认为 bottom-center
anchor: 'center',
};
var labelMarker = new AMap.LabelMarker({
name: '{ "ID": "' + data[index].ID + '","ADDR":"' + data[index].ADDR + '","NAME":"' + data[index].NAME + '","TYPE":"' + data[index].TYPE + '"}', // 此属性非绘制文字内容,仅最为标识使用
position: [point.getLng(), point.getLat()],
zIndex: 16,
// 将第一步创建的 icon 对象传给 icon 属性
icon: icon,
// 将第二步创建的 text 对象传给 text 属性
text: "",
});
labelMarker.on('click', function (e) {
//console.log(e.target.De.position);
var obj = JSON.parse(e.target.De.name)
positionLabelMarker(obj, new AMap.LngLat(e.target.De.position[0], e.target.De.position[1]));
});
if (data[index].TYPE == "2") {//取水码头
labelsLayer_qsmt.add(labelMarker);
}
else if (data[index].TYPE == "3") {//天然水源
labelsLayer_trsy.add(labelMarker);
}
else if (data[index].TYPE == "5") {//消防水鹤
labelsLayer_xfsh.add(labelMarker);
}
else if (data[index].TYPE == "6") {//消防栓
labelsLayer_xhs.add(labelMarker);
}
else if (data[index].TYPE == "7") {//微型消防站
labelsLayer_wxxfz.add(labelMarker);
}
}
}
}
//注释之后先不添加显示,后面通过按钮控制
//map.add(labelsLayer_qsmt);
//map.add(labelsLayer_trsy);
//map.add(labelsLayer_xfsh);
//map.add(labelsLayer_xhs);
//map.add(labelsLayer_wxxfz);
console.log("数据遍历完成:" + new Date());
//消防栓
$("#lab1").html("(" + labelsLayer_xhs.Yf.length + ")");
//消防水鹤
$("#lab2").html("(" + labelsLayer_xfsh.Yf.length + ")");
//天然水源
$("#lab3").html("(" + labelsLayer_trsy.Yf.length + ")");
//取水码头
$("#lab4").html("(" + labelsLayer_qsmt.Yf.length + ")");
//微型消防站
$("#lab5").html("(" + labelsLayer_wxxfz.Yf.length + ")");
}
});
}
{
//function initIco() {
// console.log("方法进入时间:" + new Date());
// $.ajax({
// type: "post",
// url: "../../ashx/FireResource.ashx",
// data: { Action: "GetWaterResource", type: "", OrgId: OrgId, random: new Date().getTime() },
// dataType: "json",
// success: function (result) {
// console.log("数据返回前台:" + new Date());
// //var data = eval("(" + result + ")");
// data = result;
// for (var index in data) {
// if (data[index].LON != "" && data[index].LAT != "") {
// if (data[index].LON != null && data[index].LON != "null" && data[index].LON != null && data[index].LON != "null" && data[index].LON != "NAN") {
// var point;
// switch (data[index].COORDINATE_TYPE) {
// case "0":
// try {
// var gcj02 = wgs84togcj02(Number(data[index].LON), Number(data[index].LAT));
// var x = gcj02[0];
// var y = gcj02[1];
// if (isNaN(x) || isNaN(y)) {
// continue;
// }
// point = new AMap.LngLat(x, y);
// } catch (ex) {
// console.log(ex);
// }
// break;
// default:
// try {
// point = new AMap.LngLat(data[index].LON, data[index].LAT);
// } catch (exc) {
// console.log(exc);
// }
// break;
// }
// var icon;
// //1、水电站;2、取水码头;3、天然水源;4、消防水池;5、消防水鹤;6、消防栓;7、微型消防站;8、重点单位;
// if (data[index].TYPE == "2") {//取水码头
// icon = IconConfig.WaterMT;
// }
// else if (data[index].TYPE == "3") {//天然水源
// icon = IconConfig.SY;
// }
// else if (data[index].TYPE == "5") {//消防水鹤
// icon = IconConfig.Crane;
// }
// else if (data[index].TYPE == "6") {//消防栓
// icon = IconConfig.XFS;
// }
// else if (data[index].TYPE == "7") {//微型消防站
// icon = IconConfig.Station;
// }
// var myIcon = new AMap.Icon({ size: new AMap.Size(40, 40), image: icon, imageSize: new AMap.Size(40, 40) });
// var marker = new AMap.Marker({
// position: point,
// icon: myIcon
// }); // 创建标注
// //map.add(marker);
// //// 将标注添加到地图中
// ////marker.id = { ID: data[index].ID, DVC_SN: data[index].DVC_SN, ADDR: data[index].ADDR, NAME: data[index].NAME, ORG_ID: data[index].ORG_ID, TYPE: data[index].TYPE, I_FORM: data[index].I_FORM, I_HEIGHT: data[index].I_HEIGHT, HYD_TYPE: data[index].HYD_TYPE, M_PRE: data[index].M_PRE, M_DIA: data[index].M_DIA, FLOW_SIZE: data[index].FLOW_SIZE, CAPACITY: data[index].CAPACITY, AREA: data[index].AREA };
// //marker.id = { ID: data[index].ID, ADDR: data[index].ADDR, NAME: data[index].NAME, TYPE: data[index].TYPE};
// //AMap.event.addListener(marker, 'click', function (e) {
// // position(e)
// //})
// //marker.hide();
// //1、水电站;2、取水码头;3、天然水源;4、消防水池;5、消防水鹤;6、消防栓;7、微型消防站;8、重点单位;
// if (data[index].TYPE == "2") {//取水码头
// arr2.push(marker);
// }
// else if (data[index].TYPE == "3") {//天然水源
// arr3.push(marker);
// }
// else if (data[index].TYPE == "5") {//消防水鹤
// arr5.push(marker);
// }
// else if (data[index].TYPE == "6") {//消防栓
// arr6.push(marker);
// }
// else if (data[index].TYPE == "7") {//微型消防站
// arr7.push(marker);
// }
// }
// }
// }
// // 创建覆盖物群组,并将 marker 传给 OverlayGroup
// var overlayGroups = new AMap.OverlayGroup(arr6);
// map.add(overlayGroups);
// console.log("数据遍历完成:" + new Date());
// //消防栓
// $("#lab1").html("(" + arr6.length + ")");
// //消防栓
// $("#lab2").html("(" + arr5.length + ")");
// //天然水源
// $("#lab3").html("(" + arr3.length + ")");
// //取水码头
// $("#lab4").html("(" + arr2.length + ")");
// //微型消防站
// $("#lab5").html("(" + arr7.length + ")");
// }
// });
//}
}//折叠注释代码
//左上角攻击条控制地图元素显示隐藏
$(".xfzy-zys").on("click", "li", function () {
var liId = $(this).attr("id");
var liDataValue = $(this).attr("data-value");
var numtype = 0;
switch (liId) {
case 'xfzy-zys-xfs': {
liDataValue == "0" ? map.add(labelsLayer_xhs) : map.remove(labelsLayer_xhs);
break;
}
case 'xfzy-zys-crane': {
liDataValue == "0" ? map.add(labelsLayer_xfsh) : map.remove(labelsLayer_xfsh);
break;
}
case 'xfzy-zys-watersouce': {
liDataValue == "0" ? map.add(labelsLayer_trsy) : map.remove(labelsLayer_trsy);
break;
}
case 'xfzy-zys-watermt': {
liDataValue == "0" ? map.add(labelsLayer_qsmt) : map.remove(labelsLayer_qsmt);
break;
}
case 'xfzy-zys-station': {
liDataValue == "0" ? map.add(labelsLayer_wxxfz) : map.remove(labelsLayer_wxxfz);
break;
}
}
liDataValue == "0" ? $(this).attr("data-value", "1").addClass("current") : $(this).attr("data-value", "0").removeClass("current");
})
//定位并弹窗
position = function (marker) {
var type = marker.target.id.TYPE;
var strhtml = "<table style='background-color:rgb(18,63,120)'>";
strhtml += "<tr><td class='tdcolorA'>名称:</td><td class='tdcolor'>" + marker.target.id.NAME + "</td></tr>";
if (type == "2") {
strhtml += "<tr><td class='tdcolorA'>地址:</td><td class='tdcolor'>" + marker.target.id.ADDR + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>取水形式:</td><td class='tdcolor'>" + marker.target.id.I_FORM + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>取水高度:</td><td class='tdcolor'>" + marker.target.id.I_HEIGHT + "</td></tr>";
}
else if (type == "3") {
strhtml += "<tr><td class='tdcolorA'>地址:</td><td class='tdcolor'>" + marker.target.id.ADDR + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>容量:</td><td class='tdcolor'>" + marker.target.id.CAPACITY + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>面积:</td><td class='tdcolor'>" + marker.target.id.AREA + "</td></tr>";
}
else if (type == "5") {
strhtml += "<tr><td class='tdcolorA'>地址:</td><td class='tdcolor'>" + marker.target.id.ADDR + "</td></tr>";
var hydType = '地上';
if (marker.target.id.HYD_TYPE == "1") {
hydType = '地下';
}
strhtml += "<tr><td class='tdcolorA'>安装位置:</td><td class='tdcolor'>" + hydType + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>管网压力:</td><td class='tdcolor'>" + marker.target.id.M_PRE + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>管网直径:</td><td class='tdcolor'>" + marker.target.id.M_DIA + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>流量大小:</td><td class='tdcolor'>" + marker.target.id.FLOW_SIZE + "</td></tr>";
}
else if (type == "6") {
strhtml += "<tr><td class='tdcolorA'>地址:</td><td class='tdcolor'>" + marker.target.id.ADDR + "</td></tr>";
var hydType = '地上';
if (marker.target.id.HYD_TYPE == "1") {
hydType = '地下';
}
strhtml += "<tr><td class='tdcolorA'>安装位置:</td><td class='tdcolor'>" + hydType + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>管网压力:</td><td class='tdcolor'>" + marker.target.id.M_PRE + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>管网直径:</td><td class='tdcolor'>" + marker.target.id.M_DIA + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>流量大小:</td><td class='tdcolor'>" + marker.target.id.FLOW_SIZE + "</td></tr>";
}
else if (type == "7") {
strhtml += "<tr><td class='tdcolorA'>地址:</td><td class='tdcolor'>" + marker.target.id.ADDR + "</td></tr>";
//strhtml += "<tr><td class='tdcolorA'>装备:</td><td class='tdcolor'>消防服3套,斧头2把,灭火器3个</td></tr>";
}
strhtml += "</table>";
infoWindow = new AMap.InfoWindow({
content: strhtml //使用默认信息窗体框样式,显示信息内容
});
infoWindow.open(map, marker.lnglat);
}
//定位并弹窗
positionLabelMarker = function (obj, lnglat) {
var type = obj.TYPE;
var strhtml = "<table style='background-color:rgb(18,63,120)'>";
strhtml += "<tr><td class='tdcolorA'>名称:</td><td class='tdcolor'>" + obj.NAME + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>地址:</td><td class='tdcolor'>" + obj.ADDR + "</td></tr>";
//中间获取专属属性
$.ajax({
type: "post",
url: "../../ashx/FireResource.ashx",
data: { Action: "GetWaterResourceSingle", ID: obj.ID, random: new Date().getTime() },
dataType: "json",
async: false,
success: function (result) {
if (type == "2") {
strhtml += "<tr><td class='tdcolorA'>取水形式:</td><td class='tdcolor'>" + result[0].I_FORM + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>取水高度:</td><td class='tdcolor'>" + result[0].I_HEIGHT + "</td></tr>";
}
else if (type == "3") {
strhtml += "<tr><td class='tdcolorA'>容量:</td><td class='tdcolor'>" + result[0].CAPACITY + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>面积:</td><td class='tdcolor'>" + result[0].AREA + "</td></tr>";
}
else if (type == "5") {
var hydType = '地上';
if (result[0].HYD_TYPE == "1") {
hydType = '地下';
}
strhtml += "<tr><td class='tdcolorA'>安装位置:</td><td class='tdcolor'>" + hydType + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>管网压力:</td><td class='tdcolor'>" + result[0].M_PRE + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>管网直径:</td><td class='tdcolor'>" + result[0].M_DIA + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>流量大小:</td><td class='tdcolor'>" + result[0].FLOW_SIZE + "</td></tr>";
}
else if (type == "6") {
var hydType = '地上';
if (result[0].HYD_TYPE == "1") {
hydType = '地下';
}
strhtml += "<tr><td class='tdcolorA'>安装位置:</td><td class='tdcolor'>" + hydType + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>管网压力:</td><td class='tdcolor'>" + result[0].M_PRE + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>管网直径:</td><td class='tdcolor'>" + result[0].M_DIA + "</td></tr>";
strhtml += "<tr><td class='tdcolorA'>流量大小:</td><td class='tdcolor'>" + result[0].FLOW_SIZE + "</td></tr>";
}
else if (type == "7") {
//strhtml += "<tr><td class='tdcolorA'>装备:</td><td class='tdcolor'>消防服3套,斧头2把,灭火器3个</td></tr>";
}
}
})
strhtml += "</table>";
infoWindow = new AMap.InfoWindow({
content: strhtml //使用默认信息窗体框样式,显示信息内容
});
infoWindow.open(map, lnglat);
}
//
//xhsdvcinfo = function (dvc_sn) {
// var index = layui.layer.open({
// title: "设备详情",
// type: 2,
// area: ["900px", "600px"],
// maxmin: true,
// content: "http://39.102.68.187:7606/DVC_DATA/dvcjiance_transfer.html?DVC_ID=" + dvc_sn + "&DVC_TYPE=0101",
// //content: "http://47.104.11.54:8075/XF_QY/QY_DIAN/dvcjiance.html?DVCID=" + dvc_sn + "&DVC_TYPE=0101",
// success: function (layero, index) {
// }
// });
//}
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ----------------------------------------------------车辆列表--------------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
var CarListfun = function () {
//车俩列表
var tableIns = table.render({
elem: '#carList',
url: '../../ashx/CarHandler.ashx',
where: { Action: 'GetCarListByIMEI', OrgId: OrgId, random: new Date().getTime() },
cellMinWidth: 95,
//page: true,
page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
, groups: 3 //只显示 1 个连续页码
, first: false //不显示首页
, last: false //不显示尾页
},
height: 365,
limits: [10, 15, 20, 25],
limit: 10,
id: "carListTable",
skin: 'line',
cols: [[
{
field: 'CAR_NUM', title: '车牌号码', minWidth: 100, align: "center", templet: function (d) {
if (d.CAR_NUM.indexOf("?") > -1) {
return d.CAR_NUM.replace("?", "");
} else {
return d.CAR_NUM;
}
}
},
{ title: '定位', width: 70, templet: '#carLocationBar', align: "center" },
{ title: '轨迹', width: 70, templet: '#trajectoryBar', align: "center" },
//{ title: '电子围栏', width: 90, templet: '#electronicFenceBar', align: "center" }
]],
done: function (res, curr, count) {
markers = [];
for (var i in res.data) {
getCarPoint(encodeURI(JSON.stringify(res.data[i])));
}
ClusterMapfun();
}
});
}
$("#carListsearchBtn").on("click", function () {
table.reload("carListTable", {
page: {
curr: 1 //重新从第 1 页开始
},
where: {
Action: 'GetCarListByIMEI',
OrgId: OrgId,
carNum: $("#carListsearchVal").val(), //搜索的关键字
random: new Date().getTime() //随机参数
}
});
});
//文本框回车事件
$('#carListsearchVal').bind('keypress', function (event) {
if (event.keyCode == "13") {
table.reload("carListTable", {
page: {
curr: 1 //重新从第 1 页开始
},
where: {
Action: 'GetCarListByIMEI',
OrgId: OrgId,
carNum: $("#carListsearchVal").val(), //搜索的关键字
random: new Date().getTime() //随机参数
}
});
}
});
//车辆列表操作
table.on('tool(carList)', function (obj) {
var layEvent = obj.event;
var data = obj.data;
if (layEvent == 'carLocation') {//定位
var FACTORY = "";
CarListArr.forEach(item => {
if (item.IMEI == data.IMEI) {
FACTORY = item.FACTORY;
return;
}
});
if (FACTORY == "1") {
$.ajax({
type: "GET",
url: _lttHTTPipUrl + "/GPS/Vehicle/VehicleLocation?vehicleNo=" + data.IMEI,
success: function (result) {
//console.log("乐兔兔车联网___车辆轨迹列表:");
console.log(result);
var point = wgs84togcj02(Number(result.Lon), Number(result.Lat));
map.setZoomAndCenter(19, point);
var infohtml = "<table>";
infohtml += "<tr><td class='tdcolorA'>车牌号:</td><td class='tdcolor'>" + data.CAR_NUM + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆名称:</td><td class='tdcolor'>" + data.CAR_NAME + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆类型:</td><td class='tdcolor'>" + data.TYPE + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆详情:</td><td class='tdcolor'>" + data.REMARKS + "</td></tr>";
infohtml += "</table>";
infoWindow.setContent(infohtml);
infoWindow.open(map, point);
},
error: function (err) {
console.log(err);
}
});
} else {
$.ajax({
type: "GET",
url: "nginx/api/v0/terminals/" + data.IMEI + "/realtime?timestamp=" + timestamp1 + "&sign=" + signCar,
async: false,
headers:
{
"sysCode": "30001",
"from": "OTHER",
"Content-Type": "application/json",
"msgId": msgId.toString()
},
success: function (result) {
var point = wgs84togcj02(result.longitude, result.latitude);
map.setZoomAndCenter(19, point);
var infohtml = "<table>";
infohtml += "<tr><td class='tdcolorA'>车牌号:</td><td class='tdcolor'>" + data.CAR_NUM + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆名称:</td><td class='tdcolor'>" + data.CAR_NAME + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆类型:</td><td class='tdcolor'>" + data.TYPE + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆详情:</td><td class='tdcolor'>" + data.REMARKS + "</td></tr>";
infohtml += "</table>";
infoWindow.setContent(infohtml);
infoWindow.open(map, point);
},
error: function (err) {
console.log(err);
}
});
}
}
else if (layEvent == 'trajectory') {//轨迹
hidecarListDivfun();
hideamapSearchfun();
$("#carnum").siblings("div.layui-form-select").find('dl').find("dd[lay-value='" + data.IMEI + "']").click();
}
else if (layEvent == 'electronicFence') {//电子围栏
window.open('MapVideoRealPlay.html?imei=' + data.IMEI, '实时视频', 'height=800, width=1500, top=100, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}
})
$("#carListDiv .minimize").click(function () {
hidecarListDivfun();
})
var hidecarListDivfun = function () {
//车辆列表
$("#tool_vehicleList").attr("src", "img/is车辆列表.png");
$("#tool_vehicleList").attr("data-value", "0");
$("#carListDiv").hide(800);
}
/**
*
* --------------------------------------------------------------------------------------------------------
* ----------------------------------------------------车辆轨迹--------------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
$("#carTraListDiv .minimize").click(function () {
hidecartraListfun();
})
var hidecartraListfun = function () {
//车辆轨迹列表
$("#carTraListDiv").hide(800);
}
//获取当前日期
var myDate = new Date();
var nowY = myDate.getFullYear();
var nowM = myDate.getMonth() + 1;
var nowD = myDate.getDate();
var enddate = nowY + "-" + (nowM < 10 ? "0" + nowM : nowM) + "-" + (nowD < 10 ? "0" + nowD : nowD);//当前日期
//获取三十天前日期
var lw = new Date(myDate - 1000 * 60 * 60 * 24 * 30);//最后一个数字30可改,30天的意思
var lastY = lw.getFullYear();
var lastM = lw.getMonth() + 1;
var lastD = lw.getDate();
var startdate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD);//三十天之前日期
//初始赋值
laydate.render({
elem: '#travelTime',
value: startdate + ' - ' + enddate,
isInitValue: true,
range: true,
done: function (value) {
if (value.indexOf(" - ") != -1 && $("#carnum").val() != null) {
var startTime = value.split(" - ")[0]
var endTime = value.split(" - ")[1];
getTraListData($("#carnum").val(), startTime, endTime);
$("#carTraListDiv").show(800);
}
}
});
$.ajax({
type: "post",
url: "../../ashx/CarHandler.ashx",
data: { Action: "GetCarListByIMEI", OrgId: OrgId },
dataType: "json",
success: function (result) {
var carnumStr = "";
result.data.forEach(function (obj, index, arr) {
carnumStr += "<option value='" + obj.IMEI + "'>" + obj.CAR_NUM + "</option>";
});
$("#carnum").append(carnumStr);
CarListArr = result.data;
form.render('select');
}
})
form.on('select(carnum)', function (data) {
var travelTime = $("#travelTime").val();
if (travelTime.indexOf(" - ") != -1 && $("#carnum").val() != null) {
var startTime = travelTime.split(" - ")[0]
var endTime = travelTime.split(" - ")[1];
getTraListData($("#carnum").val(), startTime, endTime);
$("#carTraListDiv").show(800);
}
});
var getTraListData = function (imei, startTime, endTime) {
$("#carTraTbody").html("");
imei = imei == null ? $("#carnum").val() : imei;
if (imei == null) {
layer.msg("请选择需要查询轨迹的车辆!");
return;
}
if (startTime == null || endTime == null) {
var travelTime = $("#travelTime").val();
if (travelTime.indexOf(" - ") != -1) {
startTime = travelTime.split(" - ")[0]
endTime = travelTime.split(" - ")[1];
} else {
layer.msg("请选择车辆轨迹行驶时间段!");
return;
}
}
var startTimeT = new Date(startTime).getTime();
var endTimeT = new Date(endTime).getTime();
var signCar2 = sha1("currentPage=1&endTime=" + endTimeT + "&pageSize=20&startTime=" + startTimeT + timestamp1.toString() + securityKey);
var FACTORY = "";
CarListArr.forEach(item => {
if (item.IMEI == imei) {
FACTORY = item.FACTORY;
return;
}
});
if (FACTORY == "1") {
//车辆轨迹列表 流数据
flow.load({
elem: '#carTraTbody',
isAuto: true,
done: function (page1, next1) {
var lis = [];
$.ajax({
type: "GET",
url: _lttHTTPipUrl + "/GPS/Vehicle/VehicleTravelList?vehicleNo=" + imei + "&startTime=" + startTime + "&endTime=" + endTime,
success: function (result) {
//console.log("乐兔兔车联网___车辆轨迹列表:");
//console.log(result);
layui.each(result.trackStatisticsList, function (index, item) {
var startDateTime = formatTime(item.StartTime, 'Y-M-D h:m:s');
var stopDateTime = formatTime(item.StopTime, 'Y-M-D h:m:s');
var statisticsUUID = item.Id;
var startAddress = item.StartAddress;
var stopAddress = item.StopAddress;
var averageSpeed = item.AverageSpeed;
lis.push('<tr><td>' + startDateTime + '</td><td>' + stopDateTime + '</td><td>' + averageSpeed.toFixed(3) + '</td><td><img src="img/trajectory.png" style="width:26px; height:26px; cursor:pointer;" title="轨迹渲染" onclick=\"getTraItem(\'' + statisticsUUID + '\',\'' + startAddress + '\',\'' + stopAddress + '\',\'' + FACTORY + '\')\"/></a></td></tr>');
});
next1(lis.join(''), page1 < result.totalCount / 10);
},
error: function (err) {
console.log(err);
}
});
}
});
} else {
//车辆轨迹列表 流数据
flow.load({
elem: '#carTraTbody',
isAuto: true,
done: function (page2, next2) {
var lis = [];
$.ajax({
type: "GET",
url: "nginx/api/v0/terminals/" + imei + "/trackstatistics?currentPage=1&endTime=" + endTimeT + "&pageSize=20&startTime=" + startTimeT + "&timestamp=" + timestamp1 + "&sign=" + signCar2,
async: false,
headers: {
"sysCode": "30001",
"from": "OTHER",
"Content-Type": "application/json",
"msgId": msgId.toString()
},
success: function (result) {
//console.log("车辆轨迹列表:");
//console.log(result);
layui.each(result.trackStatisticsList, function (index, item) {
var startDateTime = formatTime(item.startTime, 'Y-M-D h:m:s');
var stopDateTime = formatTime(item.stopTime, 'Y-M-D h:m:s');
var statisticsUUID = item.statisticsUUID;
var startAddress = item.startAddress;
var stopAddress = item.stopAddress;
var averageSpeed = item.averageSpeed;
lis.push('<tr><td>' + startDateTime + '</td><td>' + stopDateTime + '</td><td>' + averageSpeed.toFixed(3) + '</td><td><img src="img/trajectory.png" style="width:26px; height:26px; cursor:pointer;" title="轨迹渲染" onclick=\"getTraItem(\'' + statisticsUUID + '\',\'' + startAddress + '\',\'' + stopAddress + '\',\'' + FACTORY + '\')\"/></a></td></tr>');
});
next2(lis.join(''), page2 < result.totalCount / 10);
},
error: function (err) {
console.log(err);
}
});
}
});
}
}
var carTraMarker = null;
var carTraPolyline = null;
var carTraPassedPolyline = null;
// 创建跟速度信息展示框
var carWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(6, -25),
content: ""
});
function showTraItem() {
carTraRouteInfo.map(val => {
carTraLineArr.push(new AMap.LngLat(val.longitude, val.latitude))
})
//把之前的線路設為透明
if (carTraPolyline) {
carTraPolyline.setOptions({
strokeColor: "#000", //线颜色
strokeOpacity: 0,
})
}
if (carTraPassedPolyline) {
carTraPassedPolyline.setOptions({
strokeColor: "#000", //线颜色
strokeOpacity: 0, //线透明度
})
}
//把之前的小汽车carTraMarker清除
if (carTraMarker) {
map.remove(carTraMarker);
}
// 2.创建小汽车carTraMarker
carTraMarker = new AMap.Marker({
map: map,
position: [carTraRouteInfo[0].longitude, carTraRouteInfo[0].latitude],
icon: "https://webapi.amap.com/images/car.png",
offset: new AMap.Pixel(-26, -13),
autoRotation: true,
angle: -90,
});
// 4、绘制轨迹
carTraPolyline = new AMap.Polyline({
map: map,
path: carTraLineArr,
showDir: true,
strokeColor: "#28F", //线颜色
// strokeOpacity: 1, //线透明度
strokeWeight: 6, //线宽
// strokeStyle: "solid" //线样式
});
//5、绘制行駛過後的顏色
carTraPassedPolyline = new AMap.Polyline({
map: map,
// path: carTraLineArr,
strokeColor: "#AF5", //线颜色
// strokeOpacity: 1, //线透明度
strokeWeight: 6, //线宽
// strokeStyle: "solid" //线样式
});
//行駛過後改變顏色
carTraMarker.on('moving', function (e) {
carTraPassedPolyline.setPath(e.passedPath);
});
// 6.速度框随车辆移动
AMap.event.addListener(carTraMarker, 'moving', function (e) {
var lastLocation = e.passedPath[e.passedPath.length - 1];
carWindow.setPosition(lastLocation);
setVehicleSpeedInWidowns(lastLocation);
});
// 7.打开速度框
//carWindow.open(map, carTraMarker.getPosition());
// 8.地图自适应缩放
map.setFitView();
}
function setVehicleSpeedInWidowns(lnglat) {
for (var i = 0; i < carTraRouteInfo.length; i++) {
if (lnglat.lat == this.carTraRouteInfo[i].latitude && lnglat.lng == this.carTraRouteInfo[i].longitude) {
carWindow.setContent("速度:" + (this.carTraRouteInfo[i].speed * 3.6).toFixed(2) + "公里/时");
return;
}
}
}
function cartratooldraw(type) {
switch (type) {
case 'startAnimation': {
//开始
carTraMarker.moveAlong(carTraLineArr, 1000);
break;
}
case 'pauseAnimation': {
//暂停
carTraMarker.pauseMove();
break;
}
case 'resumeAnimation': {
//继续
carTraMarker.resumeMove();
break;
}
case 'stopAnimation': {
//停止
carTraMarker.stopMove();
break;
}
case 'speedAnimation': {
//显示气泡
if (!carWindow.getIsOpen()) { //判断窗体是否显示
carWindow.open(map, carTraMarker.getPosition());
}
break;
}
}
}
$("#cartratoolList").on("click", "button", function () {
cartratooldraw($(this).attr("id"));
})
getTraItem = function (uuid, startAddress, stopAddress, factory) {
var index = layer.load(0, { time: 10 * 1000 }); //又换了种风格,并且设定最长等待时长
if (factory == "1") {
$.ajax({
type: "GET",
url: _lttHTTPipUrl + "/GPS/Vehicle/VehicleTravelDetail?Id=" + uuid,
success: function (result) {
//console.log("乐兔兔车联网___轨迹详情:");
//console.log(result);
if (result.length <= 0) {
layer.msg("当前轨迹暂无轨迹点信息!");
return;
}
carTraLineArr = [];
carTraLineArr2 = [];
carTraRouteInfo = result;
if (carTraRouteInfo.length > 0) {
showTraItem();
} else {
window.$message.info("暂无轨迹信息!");
}
$("#cartratoolList").show();
layer.close(index);
},
error: function (err) {
console.log(err);
layer.close(index);
}
});
} else {
$.ajax({
type: "GET",
url: "nginx/api/v0/thirdpart/trackstatistics/" + uuid + "/tracks?timestamp=" + timestamp1 + "&sign=" + signCar,
async: false,
headers: {
"sysCode": "30001",
"from": "OTHER",
"Content-Type": "application/json",
"msgId": msgId.toString()
},
success: function (result) {
//console.log("轨迹详情:");
//console.log(result);
carTraLineArr = [];
carTraLineArr2 = [];
carTraRouteInfo = result.tracks
if (carTraRouteInfo.length > 0) {
showTraItem();
} else {
window.$message.info("暂无轨迹信息!");
}
$("#cartratoolList").show();
layer.close(index);
},
error: function (err) {
console.log(err);
layer.close(index);
}
});
}
}
function hidecarTraListfun() {
map.clearInfoWindow();
if (carTraMarker != null) map.remove(carTraMarker);
if (carTraPolyline != null) map.remove(carTraPolyline);
if (carTraPassedPolyline != null) map.remove(carTraPassedPolyline);
$("#carTraListDiv").hide();
$("#cartratoolList").hide();
}
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ----------------------------------------------------底部选项卡--------------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
$(".layui-tab-title li").hover(function () {
var $i = $(this).index();
$(this).addClass("layui-this").siblings().removeClass("layui-this");
$(".layui-tab-content .layui-tab-item").eq($i).addClass("layui-show").siblings().removeClass("layui-show");
});
$(".xfzy-gjl .minimize").click(function () {
$(".xfzy-gjl").hide(800);
setTimeout(function () {
$(".xfzy-gjl-show").show();
}, 750)
})
$(".xfzy-gjl-show").click(function () {
$(".xfzy-gjl").show(800);
$(".xfzy-gjl-show").hide();
})
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ----------------------------------------------------执勤力量--------------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
var OrgListfun = function () {
//执勤力量
var tableIns = table.render({
elem: '#OrgList',
url: '../../ashx/FireOrgHandler.ashx',
where: { Action: 'OrgList3', OrgId: OrgId, random: new Date().getTime() },
cellMinWidth: 95,
page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
, groups: 3 //只显示 1 个连续页码
, first: false //不显示首页
, last: false //不显示尾页
},
height: 355,
limits: [10, 15, 20, 25],
limit: 10,
id: "OrgListTable",
skin: 'line',
cols: [[
{ field: 'ORG_NAME', title: '单位名称', minWidth: 140, width: 160, align: "center" },
{ field: 'ADDR', title: '单位地址', width: 100, align: "center" },
{ field: 'CONT', title: '负责人', width: 100, align: "center" },
{ field: 'PHONE', title: '联系电话', width: 100, align: "center" }
]],
done: function (res, curr, count) {
for (var i in res.data) {
if (res.data[i].LON == null || res.data[i].LON == "" || res.data[i].LAT == null || res.data[i].LAT == "") return false;
//var marker = new AMap.Marker({ map: map, position: wgs84togcj02(Number(res.data[i].LON), Number(res.data[i].LAT)), icon: "../../images/xfz1.png" }); // 创建标注
var marker = new AMap.Marker({ map: map, position: [Number(res.data[i].LON), Number(res.data[i].LAT)], icon: "../../images/xfz1.png",zIndex: 999999 }); // 创建标注
marker.id = { ORG_ID: res.data[i].ORG_ID, ADDR: res.data[i].ADDR, ORG_NAME: res.data[i].ORG_NAME};
map.add(marker);
marker.on('click', function (e) {
var infoWindow = new AMap.InfoWindow({
content: "<div style='color: #0096ff;'>" + e.target.id.ORG_NAME + "</div>" //使用默认信息窗体框样式,显示信息内容
, offset: new AMap.Pixel(8, -30)
});
infoWindow.open(map, new AMap.LngLat(e.target.De.position.lng, e.target.De.position.lat));
});
}
}
//,response: {
// statusName: 'code', //规定返回的状态码字段为code
// statusCode: 200 //规定成功的状态码味200
//},
//parseData: function (res) {
// return {
// "code": res.code, //解析接口状态
// "msg": res.msg, //解析提示文本
// "data": res.data //解析数据列表
// }
//}
});
}
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ----------------------------------------------------应急联动--------------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
var EUnitListfun = function () {
//应急联动单位
var tableIns = table.render({
elem: '#EUnitList',
url: '../../ashx/FireUnitHandler.ashx',
where: { Action: 'UnitList', OrgId: OrgId, Type: '0', random: new Date().getTime() },
cellMinWidth: 95,
//page: true,
page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
, groups: 3 //只显示 1 个连续页码
, first: false //不显示首页
, last: false //不显示尾页
},
height: 355,
limits: [10, 15, 20, 25],
limit: 10,
id: "EUnitListTable",
skin: 'line',
cols: [[
{ field: 'NAME', title: '单位名称', minWidth: 140, width: 160, align: "center" },
{ field: 'UNIT_TYPE_NAME', title: '单位保障类型', width: 100, align: "center" },
{ field: 'UNIT_PER', title: '负责人', width: 100, align: "center" },
{ field: 'PHONE', title: '联系电话', width: 100, align: "center" }
]]
});
}
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ----------------------------------------------------联勤保障--------------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
var LUnitListfun = function () {
//联勤保障单位
var tableIns = table.render({
elem: '#LUnitList',
url: '../../ashx/FireUnitHandler.ashx',
where: { Action: 'UnitList', OrgId: OrgId, Type: '1', random: new Date().getTime() },
cellMinWidth: 95,
//page: true,
page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
, groups: 3 //只显示 1 个连续页码
, first: false //不显示首页
, last: false //不显示尾页
},
height: 355,
limits: [10, 15, 20, 25],
limit: 10,
id: "LUnitListTable",
skin: 'line',
cols: [[
{ field: 'NAME', title: '单位名称', minWidth: 140, width: 160, align: "center" },
{ field: 'UNIT_TYPE_NAME', title: '单位保障类型', width: 100, align: "center" },
{ field: 'UNIT_PER', title: '负责人', width: 100, align: "center" },
{ field: 'PHONE', title: '联系电话', width: 100, align: "center" }
]]
});
}
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ----------------------------------------------------专家信息--------------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
var ExpertListfun = function () {
//专家信息
var tableIns = table.render({
elem: '#ExpertList',
url: '../../ashx/FireExpertHandler.ashx',
where: { Action: 'ExpertList', OrgId: OrgId, random: new Date().getTime() },
cellMinWidth: 95,
//page: true,
page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
, groups: 3 //只显示 1 个连续页码
, first: false //不显示首页
, last: false //不显示尾页
},
height: 355,
limits: [10, 15, 20, 25],
limit: 10,
id: "ExpertListTable",
skin: 'line',
cols: [[
{ field: 'UNIT_NAME', title: '单位名称', minWidth: 140, width: 160, align: "center" },
{ field: 'NAME', title: '专家名称', width: 100, align: "center" },
{ field: 'FIELD_NAME', title: '领域', width: 100, align: "center" },
{ field: 'M_PHONE', title: '联系电话', width: 100, align: "center" }
]]
});
}
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ------------------------------------------------------POI关键字检索-------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
//POI查询
$("#amapSearchBtn").on("click", function () {
placeSearch.search($("#amapSearchVal").val());
});
//资源查询
$("#ResourceSearchBtn").on("click", function () {
resourceSearch($("#amapSearchVal").val());
});
////文本框回车事件
//$('#amapSearchVal').bind('keypress', function (event) {
// if (event.keyCode == "13") {
// //关键字查询
// placeSearch.search($("#amapSearchVal").val());
// }
//});
function initPlaceSearchfun(city) {
AMap.service(["AMap.Autocomplete", "AMap.PlaceSearch", "AMap.Geocoder"], function () {
//构造地点查询类
placeSearch = new AMap.PlaceSearch({
pageSize: 10, // 单页显示结果条数
pageIndex: 1, // 页码
city: city, // 兴趣点城市 (***************此处要做设置)
citylimit: true, //是否强制限制在设置的城市内搜索
map: map, // 展现结果的地图实例
panel: "amapSearchContent",// 结果列表将在此容器中进行展示。
autoFitView: true, // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
type: "汽车服务|汽车销售|汽车维修|摩托车服务|餐饮服务|购物服务|生活服务|体育休闲服务|医疗保健服务|住宿服务|风景名胜|商务住宅|政府机构及社会团体|科教文化服务|交通设施服务|金融保险服务|公司企业|道路附属设施|地名地址信息|公共设施",
extensions: "all"
});
geocoder = new AMap.Geocoder({
city: city,
})
var autoOptions = {
city: city,
input: "work-location"
};
});
}
function resourceSearch() {
}
var hideamapSearchfun = function () {
//POI搜索
placeSearch.clear();
$("#tool_search").attr("src", "img/is搜索.png");
$("#tool_search").attr("data-value", "0");
$("#amapSearchDiv").hide(800);
}
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ------------------------------------------------------路径规划-------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
var pathPlanningpath = [];
var pathPlanningmarks = [];
function showInfoClick(e) {
//绘制初始路径
pathPlanningpath.push([e.lnglat.getLng(), e.lnglat.getLat()]);
pathPlanningmarker = new AMap.Marker({
icon: "../../images/s_point.png",
position: [e.lnglat.getLng(), e.lnglat.getLat()],
offset: new AMap.Pixel(-13, -30)
});
pathPlanningmarker.setMap(map);
pathPlanningmarks.push(pathPlanningmarker);
if (pathPlanningpath.length > 1) {
map.plugin("AMap.DragRoute", function () {
//if (typeof pathPlanningroute1 !== "undefined") { pathPlanningroute1.destroy(); } //如果存在,先销毁
//if (typeof pathPlanningroute2 !== "undefined") { pathPlanningroute2.destroy(); } //如果存在,先销毁
//if (typeof pathPlanningroute3 !== "undefined") { pathPlanningroute3.destroy(); } //如果存在,先销毁
if (typeof pathPlanningroute4 !== "undefined") { pathPlanningroute4.destroy(); } //如果存在,先销毁
//pathPlanningroute1 = new AMap.DragRoute(map, pathPlanningpath, AMap.DrivingPolicy.LEAST_FEE); //最经济
//pathPlanningroute1.search(); //查询导航路径并开启拖拽导航
//pathPlanningroute2 = new AMap.DragRoute(map, pathPlanningpath, AMap.DrivingPolicy.LEAST_TIME); //时间最少
//pathPlanningroute2.search(); //查询导航路径并开启拖拽导航
//pathPlanningroute3 = new AMap.DragRoute(map, pathPlanningpath, AMap.DrivingPolicy.LEAST_DISTANCE); //最短距离
//pathPlanningroute3.search(); //查询导航路径并开启拖拽导航
pathPlanningroute4 = new AMap.DragRoute(map, pathPlanningpath, AMap.DrivingPolicy.REAL_TRAFFIC); //考虑实际路况
pathPlanningroute4.search(); //查询导航路径并开启拖拽导航
});
map.off("click", showInfoClick);
pathPlanningmarks.forEach(function (value) {
value.setMap(null);
value = null;
});
pathPlanningpath = [];
pathPlanningmarks = [];
}
}
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ----------------------------------------------------右上角工具栏----------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
function toolListdraw(type) {
switch (type) {
case 'ranging': {
//测距
if ($("#ranging").attr("data-value") == "1") {
$("#ranging").attr("src", "img/is测量.png");
$("#ranging").attr("data-value", "0");
mouseTool.close(true);
} else {
$("#ranging").attr("src", "img/测量.png");
$("#ranging").attr("data-value", "1");
$("#measureArea").attr("src", "img/is面积.png");
$("#measureArea").attr("data-value", "0");
mouseTool.rule({
startMarkerOptions: {
icon: new AMap.Icon({
size: new AMap.Size(19, 31),
imageSize: new AMap.Size(19, 31),
image: "img/起.png"
})
},
endMarkerOptions: {
icon: new AMap.Icon({
size: new AMap.Size(19, 31),
imageSize: new AMap.Size(19, 31),
image: "img/终.png"
}),
offset: new AMap.Pixel(-9, -31)
},
midMarkerOptions: {
icon: new AMap.Icon({
size: new AMap.Size(19, 31),
imageSize: new AMap.Size(19, 31),
image: "img/经.png"
}),
offset: new AMap.Pixel(-9, -31)
},
lineOptions: {
strokeStyle: "solid",
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 2
}
});
}
break;
}
case 'measureArea': {
//测面
if ($("#measureArea").attr("data-value") == "1") {
$("#measureArea").attr("src", "img/is面积.png");
$("#measureArea").attr("data-value", "0");
mouseTool.close(true);
} else {
$("#measureArea").attr("src", "img/面积.png");
$("#measureArea").attr("data-value", "1");
$("#ranging").attr("src", "img/is测量.png");
$("#ranging").attr("data-value", "0");
mouseTool.measureArea({
strokeColor: '#80d8ff',
fillColor: '#80d8ff',
fillOpacity: 0.3
});
}
break;
}
case 'printing': {
//打印
window.print();
break;
}
//case 'roam': {
// //漫游
// break;
//}
case 'fullScreen': {
//全屏
if ($("#fullScreen").attr("data-value") == "1") {
window.parent.$(".zh-header").hide();
window.parent.$(".rcgl-left").hide();
window.parent.$("#mainDiv").css("height", "100%");
window.parent.$("#mainDiv").removeClass("rcgl-right");
window.parent.$(".rcgl-content").css("top", "0");
$("#fullScreen").attr("src", "img/缩小.png");
$("#fullScreen").attr("title", "退出全屏");
$("#fullScreen").attr("data-value", "0");
} else {
window.parent.$(".zh-header").show();
window.parent.$(".rcgl-left").show();
window.parent.$("#mainDiv").attr("class", "rcgl-right");
window.parent.$(".rcgl-content").css("top", "81px");
$("#fullScreen").attr("src", "img/放大.png");
$("#fullScreen").attr("title", "全屏");
$("#fullScreen").attr("data-value", "1");
}
break;
}
case 'tool_vehicleList': {
//车辆列表
if ($("#tool_vehicleList").attr("data-value") == "1") {
hidecarListDivfun();
} else {
$("#tool_vehicleList").attr("src", "img/车辆列表.png");
$("#tool_vehicleList").attr("data-value", "1");
$("#carListDiv").show(800);
hidecarTraListfun();
hideamapSearchfun();
}
break;
}
case 'tool_search': {
//搜索
if ($("#tool_search").attr("data-value") == "1") {
hideamapSearchfun();
} else {
$("#tool_search").attr("src", "img/搜索.png");
$("#tool_search").attr("data-value", "1");
$("#amapSearchDiv").show(800);
hidecarListDivfun();
hidecarTraListfun();
}
break;
}
case 'tool_traffic': {
//实时路况
if ($("#tool_traffic").attr("data-value") == "1") {
$("#tool_traffic").attr("src", "img/is实时路况.png");
$("#tool_traffic").attr("data-value", "0");
trafficLayer.hide();
} else {
$("#tool_traffic").attr("src", "img/实时路况.png");
$("#tool_traffic").attr("data-value", "1");
trafficLayer.show();
}
break;
}
case 'tool_pathPlanning': {
//路径规划
if ($("#tool_pathPlanning").attr("data-value") == "1") {
$("#tool_pathPlanning").attr("src", "img/is路径规划.png");
$("#tool_pathPlanning").attr("data-value", "0");
map.off("click", showInfoClick);
pathPlanningmarks.forEach(function (value) {
value.setMap(null);
value = null;
});
pathPlanningpath = [];
pathPlanningmarks = [];
pathPlanningroute4.destroy();
} else {
$("#tool_pathPlanning").attr("src", "img/路径规划.png");
$("#tool_pathPlanning").attr("data-value", "1");
map.on("click", showInfoClick);
}
break;
}
}
}
$("#toolList").on("click", "img", function () {
toolListdraw($(this).attr("id"));
})
/**
*
*
* --------------------------------------------------------------------------------------------------------
* ----------------------------------------------------地图操作--------------------------------------------
* --------------------------------------------------------------------------------------------------------
*
*/
//初始化地图
var initMap = function (lon, lat, city) {
map = new AMap.Map('map', {
resizeEnable: true,
center: [lon, lat],
zoom: 16,
mapStyle: 'amap://styles/00194a4804e32522874c56d6bf828a2c' //设置地图的显示样式 //6552e0b442bbfac5c53fc15318c01316
});
mouseTool = new AMap.MouseTool(map);
infoWindow = new AMap.InfoWindow({ offset: new AMap.Pixel(0, -30) });
CarListfun();
OrgListfun();
EUnitListfun();
//LUnitListfun();
ExpertListfun();
$(".xfzy-gjl").hide();
$(".xfzy-gjl-show").show();
initPlaceSearchfun(city);
//实时路况图层
trafficLayer = new AMap.TileLayer.Traffic({ map: map, zIndex: 10 });
trafficLayer.hide();
}
//地图显示车辆位置
var getCarPoint = function (data) {
data = JSON.parse(decodeURI(data));
if (data.FACTORY == "1") {
//乐兔兔车联网
$.ajax({
type: "GET",
url: _lttHTTPipUrl + "/GPS/Vehicle/VehicleLocation?vehicleNo=" + data.IMEI,
success: function (result) {
//console.log("乐兔兔车联网___车辆定位:");
//console.log(result);
var icon = "img/消防车.png";
if (data.CLASS == '0') icon = "img/公务车.png";
var marker = new AMap.Marker({ map: map, position: wgs84togcj02(Number(result.Lon), Number(result.Lat)), icon: icon }); // 创建标注
marker.id = data.IMEI;
marker.orderno = data.FACTORY;
var infohtml = "<table>";
infohtml += "<tr><td class='tdcolorA'>定位时间:</td><td class='tdcolor'>" + result.ReportTime + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车牌号:</td><td class='tdcolor'>" + data.CAR_NUM + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆名称:</td><td class='tdcolor'>" + data.CAR_NAME + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆类型:</td><td class='tdcolor'>" + data.TYPE + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆详情:</td><td class='tdcolor'>" + data.REMARKS + "</td></tr>";
infohtml += "</table>";
marker.content = infohtml;
marker.on('click', markerClick);
marker.on('rightclick', markerRightClick);
markers.push(marker);
},
error: function (err) {
console.log(err);
}
});
} else {
$.ajax({
type: "GET",
url: "nginx/api/v0/terminals/" + data.IMEI + "/realtime?timestamp=" + timestamp1 + "&sign=" + signCar,
async: false,
headers:
{
"sysCode": "30001",
"from": "OTHER",
"Content-Type": "application/json",
"msgId": msgId.toString()
},
success: function (result) {
//console.log("中移物联车联网___车辆定位:");
//console.log(result);
if (result.runStatus == "STARTED") {
//启动
} else if (result.runStatus == "STOPPED") {
//熄火
}
var icon = "img/消防车.png";
if (data.CLASS == '0') icon = "img/公务车.png";
//console.log(icon);
var marker = new AMap.Marker({ map: map, position: wgs84togcj02(Number(result.longitude), Number(result.latitude)), icon: icon }); // 创建标注
marker.id = data.IMEI;
marker.orderno = data.FACTORY;
var infohtml = "<table>";
infohtml += "<tr><td class='tdcolorA'>车牌号:</td><td class='tdcolor'>" + data.CAR_NUM + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆名称:</td><td class='tdcolor'>" + data.CAR_NAME + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆类型:</td><td class='tdcolor'>" + data.TYPE + "</td></tr>";
infohtml += "<tr><td class='tdcolorA'>车辆详情:</td><td class='tdcolor'>" + data.REMARKS + "</td></tr>";
infohtml += "</table>";
marker.content = infohtml;
marker.on('click', markerClick);
marker.on('rightclick', markerRightClick);
markers.push(marker);
},
error: function (err) {
console.log(err);
}
});
}
}
//地图图标左键事件
function markerClick(e) {
infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition());
}
//地图图标右键事件
function markerRightClick(e) {
var contextMenu = new AMap.ContextMenu();
contextMenu.addItem("车载视频", function () {
window.open('MapVideoRealPlay.html?imei=' + e.target.id, '实时视频', 'height=800, width=1500, top=100, left=200, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}, 0);
contextMenu.addItem("轨迹回放", function () {
hidecarListDivfun();
hideamapSearchfun();
$("#carnum").siblings("div.layui-form-select").find('dl').find("dd[lay-value='" + e.target.id + "']").click();
}, 1);
contextMenu.open(map, e.lnglat);
}
ClusterMapfun = function () {
if (cluster) {
cluster.setMap(null);
}
cluster = new AMap.MarkerClusterer(map, markers, { gridSize: 80, maxZoom: 17 });
}
})