//开始获取接口
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;
//echarts = layui.echarts;
var OrgId = $.getShowDataJGToOrgId(JSON.parse(window.sessionStorage.getItem("userInfo")).OrgID);
//var OrgId = "fbbb44bb458c4336a84e009df74c8598";//石河子
//根据当前登陆人机构ID获取机构所在经纬度
$.ajax({
type: "post",
url: "../../ashx/ZYFireOrgHandler.ashx",
data: { Action: "getFireOrgName", ID: OrgId },
dataType: "json",
success: function (result) {
initMap(result.data.LON, result.data.LAT, result.data.CITY);
}
})
//配置各地图加载项图片
var IconConfig = {
SY: "../../images/trsy.png", //水源
Station: "../../images/xfz1.png", //消防站
XFS: "../../images/xfs1.png", //消防栓
Crane: "../../images/xfsk1.png",
WaterMT: "../../images/qsmt.png",
Zddw: "../../images/dw.png" //重点单位
};
//坐标转换
//var convertor = new BMap.Convertor();
var pointArr = [], pointStateArr = [], carIcon = "";
//存储不同类型的点
var arr2 = [], arr3 = [], arr4 = [], arr5 = [], arr6 = [], arr7 = [];
$.ajax({
type: "post",
url: "/ashx/ZYFireResource.ashx",
data: { Action: "GetWaterResource", type: "", OrgId: OrgId, random: new Date().getTime() },
dataType: "json",
success: function (result) {
//var data = eval("(" + result + ")");
data = result;
var qsmt = 0;
var trsy = 0;
var xfsh = 0;
var xfs = 0;
var wxxfz = 0;
var zddw = 0;
for (var index in data) {
try {
//if (data[index].LON != "" && data[index].LAT != "") {
//if (data[index].LON > 70 && data[index].LON < 90 && data[index].LAT < 42.933003) {
if (data[index].LON != null && data[index].LON != "null" && data[index].LON != "NAN" && data[index].LON != ""
&& data[index].LAT != null && data[index].LAT != "null" && data[index].LAT != "NAN" && data[index].LAT != "") {
// var lon=Number(data[index].LON) + Number(0.0088229865);
// var lat = Number(data[index].LAT) + Number(0.0067671027);
var gcj02 = wgs84togcj02(Number(data[index].LON), Number(data[index].LAT));
var point = new AMap.LngLat(Number(gcj02[0]), Number(gcj02[1]));
var icon;
if (data[index].TYPE == "2") {//取水码头
icon = IconConfig.WaterMT;
qsmt += 1;
}
else if (data[index].TYPE == "3") {//天然水源
icon = IconConfig.SY;
trsy += 1;
}
else if (data[index].TYPE == "8") {//重点单位
icon = IconConfig.Zddw;
zddw += 1;
}
else if (data[index].TYPE == "5") {//消防水鹤
icon = IconConfig.Crane;
xfsh += 1;
}
else if (data[index].TYPE == "6") {//消防栓
icon = IconConfig.XFS;
xfs += 1;
}
else if (data[index].TYPE == "7") {//微型消防站
icon = IconConfig.Station;
wxxfz += 1;
}
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 };
AMap.event.addListener(marker, 'click', function (e) {
position(e)
})
marker.hide();
if (data[index].TYPE == "2") {//取水码头
arr2.push(marker);
}
else if (data[index].TYPE == "3") {//天然水源
arr3.push(marker);
}
else if (data[index].TYPE == "8") {//重点单位
arr4.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);
}
}
} catch (ex) {
console.log(ex);
}
}
$("#QSMTTEST").html(qsmt);
$("#TRSYTEST").html(trsy);
$("#XFSHTEST").html(xfsh);
$("#XFSTEST").html(xfs);
$("#WXXFZTEST").html(wxxfz);
$("#ZDDWTEST").html(zddw);
},
error: function (e) {
console.log(e);
}
});
$(".zyyzt-xfsb").on("click", "li", function () {
var liId = $(this).attr("id");
var liDataValue = $(this).attr("data-value");
var numtype = 0;
switch (liId) {
case 'xfzy-zys-xfs': {
numtype = 6;
break;
}
case 'xfzy-zys-crane': {
numtype = 5;
break;
}
case 'xfzy-zys-zzdw': {
numtype = 4;
break;
}
case 'xfzy-zys-watersouce': {
numtype = 3;
break;
}
case 'xfzy-zys-watermt': {
numtype = 2;
break;
}
case 'xfzy-zys-station': {
numtype = 7;
break;
}
}
$(this).toggleClass("current");
if (liDataValue == "0") {
show2(numtype);
$(this).attr("data-value", "1");
} else if (liDataValue == "1") {
hide2(numtype);
$(this).attr("data-value", "0");
}
})
hide2 = function (type) {
var arrdata = [];
if (type == "2") {
arrdata = arr2;
}
else if (type == "3") {
arrdata = arr3;
}
else if (type == "4") {
arrdata = arr4;
}
else if (type == "5") {
arrdata = arr5;
}
else if (type == "6") {
arrdata = arr6;
}
else if (type == "7") {
arrdata = arr7;
}
//map.clearOverlays();
for (var i = 0; i < arrdata.length; i++) {
arrdata[i].hide();
}
}
show2 = function (type) {
var arrdata = [];
if (type == "2") {
arrdata = arr2;
}
else if (type == "3") {
arrdata = arr3;
}
else if (type == "4") {
arrdata = arr4;
}
else if (type == "5") {
arrdata = arr5;
}
else if (type == "6") {
arrdata = arr6;
}
else if (type == "7") {
arrdata = arr7;
}
for (var i = 0; i < arrdata.length; i++) {
arrdata[i].show();
}
//AddGraphicToMap(arrdata);
}
//定位并弹窗
var ccc;
position = function (marker) {
var type = marker.target.id.TYPE;
var strhtml = "
";
strhtml += "名称: | " + marker.target.id.NAME + " |
";
if (type == "2") {
strhtml += "地址: | " + marker.target.id.ADDR + " |
";
//strhtml += "水量: | 7000m³ |
";
}
else if (type == "3") {
strhtml += "地址: | " + marker.target.id.ADDR + " |
";
/* strhtml += "水量: | 10000m³ |
";*/
}
else if (type == "8") {
//strhtml += "单位名称: | " + marker.target.id.NAME + " |
";
/* strhtml += "水量: | 10000m³ |
";*/
}
else if (type == "5") {
strhtml += "地址: | " + marker.target.id.ADDR + " |
";
}
else if (type == "6") {
strhtml += "地址: | " + marker.target.id.ADDR + " |
";
var ppp = Math.floor(Math.random() * 10);
var yyy = ppp.toString();
var mmm = Math.floor(Math.random() * (5 - 1 + 1) + 1) / 10;
console.log(mmm + yyy)
ccc = mmm + yyy
//strhtml += "水压: | " + ccc+"Mpa |
";
strhtml += "";
setTimeout(() => {
initMarkCharts();
}, 100)
}
else if (type == "7") {
strhtml += "地址: | " + marker.target.id.ADDR + " |
";
//strhtml += "装备: | 消防服3套,斧头2把,灭火器3个 |
";
}
strhtml += "
";
infoWindow = new AMap.InfoWindow({
content: strhtml //使用默认信息窗体框样式,显示信息内容
});
infoWindow.open(map, marker.lnglat);
}
initMarkCharts = function () {
var myChart = echarts.init(document.getElementById('chartsMain'));
// 指定图表的配置项和数据
let colors = ['#FD666D', '#37A2DA', '#FD666D'];
option = {
backgroundColor: '#123F78',
series: [{
// name: 'CPU使用率',
type: 'gauge',
center: ["50%", "50%"], // 仪表位置
radius: "100%", //仪表大小
min: 0,
max: 1,
axisLine: {
// 仪表盘
lineStyle: {
width: 20,
color: [
[0.1, colors[0]],
[0.7, colors[1]],
[1, colors[2]]
]
}
},
splitLine: {
// 分隔线样式
length: "12%"
},
axisTick: {
// 刻度样式
show: false
},
axisLabel: {
// 刻度标签
fontSize: 16,
fontWeight: 'bold',
distance: 10
},
pointer: {
// 仪表盘指针
icon: 'none',
width: 10,
length: "60%"
},
markPoint: {
// 仪表盘指针圆
animation: false,
silent: true,
data: [{
x: '50%',
y: '50%',
symbol: 'circle',
symbolSize: 50,
// itemStyle: {
// color: '#1890ff',
// },
}, {
x: '50%',
y: '50%',
symbol: 'circle',
symbolSize: 30,
itemStyle: {
color: '#fff'
},
}]
},
detail: {
// 仪表盘 显示数据
formatter: '水压:{value}MPa',
fontSize: 14,
fontWeight: 'bold'
},
data: [{
value: ccc,
// name: ""
}],
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
}
//
//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/ZYCarHandler.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;
console.log(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 = "";
infohtml += "车牌号: | " + data.CAR_NUM + " |
";
infohtml += "车辆名称: | " + data.CAR_NAME + " |
";
infohtml += "车辆类型: | " + data.TYPE + " |
";
infohtml += "车辆详情: | " + data.REMARKS + " |
";
infohtml += "
";
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 = "";
infohtml += "车牌号: | " + data.CAR_NUM + " |
";
infohtml += "车辆名称: | " + data.CAR_NAME + " |
";
infohtml += "车辆类型: | " + data.TYPE + " |
";
infohtml += "车辆详情: | " + data.REMARKS + " |
";
infohtml += "
";
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/ZYCarHandler.ashx",
data: { Action: "GetCarListByIMEI", OrgId: OrgId },
dataType: "json",
success: function (result) {
var carnumStr = "";
result.data.forEach(function (obj, index, arr) {
carnumStr += "";
});
$("#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('' + startDateTime + ' | ' + stopDateTime + ' | ' + averageSpeed.toFixed(3) + ' |  |
');
});
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 + "×tamp=" + 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('' + startDateTime + ' | ' + stopDateTime + ' | ' + averageSpeed.toFixed(3) + ' |  |
');
});
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, startTime, endTime, factory) {
var index = layer.load(0, { time: 10 * 1000 }); //又换了种风格,并且设定最长等待时长
if (factory == "1") {
$.ajax({
type: "GET",
url: _lttHTTPipUrl + "/GPS/Vehicle/VehicleTravelDetail?Id=" + uuid + "&startTime=" + startTime + "&endTime=" + endTime,
success: function (result) {
//console.log("乐兔兔车联网___轨迹详情:");
//console.log(result);
if (result.length <= 0) {
layer.msg("当前轨迹暂无轨迹点信息!");
return;
}
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);
}
});
} 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/ZYFireOrgHandler.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" }); // 创建标注
map.add(marker);
}
}
//,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/ZYFireUnitHandler.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/ZYFireUnitHandler.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/ZYFireExpertHandler.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 = "";
infohtml += "定位时间: | " + result.ReportTime + " |
";
infohtml += "车牌号: | " + data.CAR_NUM + " |
";
infohtml += "车辆名称: | " + data.CAR_NAME + " |
";
infohtml += "车辆类型: | " + data.TYPE + " |
";
infohtml += "车辆详情: | " + data.REMARKS + " |
";
infohtml += "
";
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 = "";
infohtml += "车牌号: | " + data.CAR_NUM + " |
";
infohtml += "车辆名称: | " + data.CAR_NAME + " |
";
infohtml += "车辆类型: | " + data.TYPE + " |
";
infohtml += "车辆详情: | " + data.REMARKS + " |
";
infohtml += "
";
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 });
}
})