<%--
|
Created by IntelliJ IDEA.
|
User: Lenovo
|
Date: 2024/6/11
|
Time: 11:32
|
To change this template use File | Settings | File Templates.
|
--%>
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
<html>
|
<head>
|
<title>Title</title>
|
<style>
|
*{
|
margin: 0;
|
padding: 0;
|
}
|
#titles{
|
background: url("/hxzkuwb/Home/HomeImg/title.png")no-repeat;
|
background-position: center;
|
}
|
</style>
|
</head>
|
<body>
|
<div class="layui-container" style="width: 100%;">
|
<div class="layui-row">
|
<div class="layui-col-xs12 layui-col-md12" style="width: 100%;height: 10%;position: fixed;z-index: 9">
|
<h1 style="text-align: center;color: white" id="titles">定位管理系统</h1>
|
</div>
|
</div>
|
<div class="layui-row">
|
<div class="layui-col-xs12 layui-col-md12" style="width: 100%;height: 100%;" id="container">
|
</div>
|
</div>
|
</div>
|
</body>
|
<script src="../HouTai/Js/jquery-3.5.1.js"></script>
|
<script src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=zoVtgLNWuaZBjMAa32RZRFIagXxST0fm"></script>
|
<script>
|
var bm = new BMapGL.Map("container");
|
bm.centerAndZoom(new BMapGL.Point(116.404, 39.915), 12); // 初始化地图,设置中心点坐标和地图级别
|
bm.setMapType(BMAP_EARTH_MAP);
|
bm.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放
|
bm.setHeading(64.5);
|
bm.setTilt(73);
|
bm.setDisplayOptions({
|
skyColors: ['rgba(186, 0, 255, 0)','rgba(186, 0, 255, 0.2)']
|
})
|
|
|
var zuobiaoxi = "";
|
//从数据库查询当前选择的什么系坐标
|
$.ajax({
|
url: "/hxzkuwb/findbaidumapList",
|
type: "GET",
|
async: false,
|
success: function(data) {
|
zuobiaoxi = data[0].zhuanhuan
|
}
|
});
|
var markers = {};
|
var markers1 = {};
|
var timer = setInterval(function() {
|
markers = {};
|
bm.clearOverlays();
|
//只显示在线
|
var gps_node_list1 = getGPS();
|
for (var i = 0; i < gps_node_list1.length; i++) {
|
var gpsInfo = gps_node_list1[i];
|
var c = new Convertor();
|
if(gpsInfo.baoliu2>10){
|
var rr = c.WGS2BD09({ lng: parseFloat(gpsInfo.baoliu2), lat: parseFloat(gpsInfo.baoliu3)});
|
if (zuobiaoxi == "百度"){
|
var lng = parseFloat(rr.lng);
|
var lat = parseFloat(rr.lat);
|
|
}else{
|
var lng = parseFloat(gpsInfo.baoliu2);
|
var lat = parseFloat(gpsInfo.baoliu3);
|
}
|
var userId = gpsInfo.ptagid;
|
// 判断在线状态
|
localStorage.setItem("username","超级管理员")
|
if(gpsInfo.psos == "1") {
|
if (markers1.hasOwnProperty(userId)) {
|
// 如果已经存在该标记,则移除原来的标记
|
bm.removeOverlay(markers1[userId]);
|
// 更新标记位置
|
const customOverlay = new BMapGL.CustomOverlay(createDOM, {
|
point: new BMapGL.Point(lng, lat),
|
opacity: 1,
|
bm: bm,
|
offsetY: 26,
|
zIndex: -1
|
});
|
bm.addOverlay(customOverlay);
|
markers1[userId] = customOverlay;
|
} else {
|
// 如果不存在该标记,则添加新标记
|
const customOverlay = new BMapGL.CustomOverlay(createDOM, {
|
point: new BMapGL.Point(lng, lat),
|
opacity: 1,
|
bm: bm,
|
offsetY: 26,
|
zIndex: -1
|
});
|
bm.addOverlay(customOverlay);
|
markers1[userId] = customOverlay;
|
}
|
}else{
|
if (markers1.hasOwnProperty(userId)) {
|
// 如果已经存在该标记,则移除原来的标记
|
bm.removeOverlay(markers1[userId]);
|
}
|
}
|
// 创建坐标点
|
var point = new BMapGL.Point(lng, lat);
|
// 创建标记
|
var myIcon = new BMapGL.Icon("../Icon/"+gpsInfo.pimage, new BMapGL.Size(40, 40), {
|
|
});
|
var marker = new BMapGL.Marker(point, { icon: myIcon });
|
|
// 将标记添加到地图上
|
bm.addOverlay(marker);
|
var label = new BMapGL.Label(gpsInfo.pname+" "+userId,{offset: new BMapGL.Size(0, -50)});
|
label.setStyle({
|
color: "#fff",
|
fontSize: "14px",
|
borderRadius: "5px",
|
padding: "5px 5px",
|
border: "0",
|
backgroundColor: gpsInfo.bumencolor,
|
transform: 'translateX(-50%)',
|
});
|
marker.setLabel(label);
|
// 存储标记到 markers 对象中
|
markers[userId] = marker;
|
marker.setTitle(gpsInfo.ptagid);
|
}
|
}
|
|
}, 2000);
|
|
|
function getGPS() {
|
var gpslist = [];
|
$.ajax({
|
async: false,
|
type: 'POST',
|
traditional: true,
|
url: "/hxzkuwb/getGPS",
|
dataType: 'json',
|
data: {},
|
success: function (data) {
|
//经纬度从度分秒转成度
|
gpslist = data
|
},
|
});
|
return gpslist;
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Convertor(ak) {
|
this.stepCount = 100;
|
this.pointCount = [];
|
this.Result = [];
|
this.NoisIndex = [];
|
this.Time = new Date();
|
this.AK = ak;
|
this.M_PI = 3.14159265358979324;
|
this.A = 6378245.0;
|
this.EE = 0.00669342162296594323;
|
this.X_PI = this.M_PI * 3000.0 / 180.0;
|
}
|
Convertor.prototype.outofChine = function (p) {
|
if (p.lng < 72.004 || p.lng > 137.8347) {
|
return true;
|
}
|
if (p.lat < 0.8293 || p.lat > 55.8271) {
|
return true;
|
}
|
return false;
|
}
|
;
|
Convertor.prototype.WGS2GCJ_lat = function (x, y) {
|
var ret1 = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
|
ret1 += (20.0 * Math.sin(6.0 * x * this.M_PI) + 20.0 * Math.sin(2.0 * x * this.M_PI)) * 2.0 / 3.0;
|
ret1 += (20.0 * Math.sin(y * this.M_PI) + 40.0 * Math.sin(y / 3.0 * this.M_PI)) * 2.0 / 3.0;
|
ret1 += (160.0 * Math.sin(y / 12.0 * this.M_PI) + 320 * Math.sin(y * this.M_PI / 30.0)) * 2.0 / 3.0;
|
return ret1;
|
}
|
;
|
Convertor.prototype.WGS2GCJ_lng = function (x, y) {
|
var ret2 = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
|
ret2 += (20.0 * Math.sin(6.0 * x * this.M_PI) + 20.0 * Math.sin(2.0 * x * this.M_PI)) * 2.0 / 3.0;
|
ret2 += (20.0 * Math.sin(x * this.M_PI) + 40.0 * Math.sin(x / 3.0 * this.M_PI)) * 2.0 / 3.0;
|
ret2 += (150.0 * Math.sin(x / 12.0 * this.M_PI) + 300.0 * Math.sin(x / 30.0 * this.M_PI)) * 2.0 / 3.0;
|
return ret2;
|
}
|
;
|
Convertor.prototype.WGS2GCJ = function (poi) {
|
if (this.outofChine(poi)) {
|
return;
|
}
|
var poi2 = {};
|
var dLat = this.WGS2GCJ_lat(poi.lng - 105.0, poi.lat - 35.0);
|
var dLon = this.WGS2GCJ_lng(poi.lng - 105.0, poi.lat - 35.0);
|
var radLat = poi.lat / 180.0 * this.M_PI;
|
var magic = Math.sin(radLat);
|
magic = 1 - this.EE * magic * magic;
|
var sqrtMagic = Math.sqrt(magic);
|
dLat = (dLat * 180.0) / ((this.A * (1 - this.EE)) / (magic * sqrtMagic) * this.M_PI);
|
dLon = (dLon * 180.0) / (this.A / sqrtMagic * Math.cos(radLat) * this.M_PI);
|
poi2.lat = poi.lat + dLat;
|
poi2.lng = poi.lng + dLon;
|
return poi2;
|
}
|
;
|
Convertor.prototype.GCJ2BD09 = function (poi) {
|
var poi2 = {};
|
var x = poi.lng
|
, y = poi.lat;
|
var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * this.X_PI);
|
var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.X_PI);
|
poi2.lng = z * Math.cos(theta) + 0.0065;
|
poi2.lat = z * Math.sin(theta) + 0.006;
|
return poi2;
|
}
|
;
|
/**
|
* WGS->百度坐标系
|
*/
|
Convertor.prototype.WGS2BD09 = function (poi) {
|
//WGS->GCJ
|
var poi2 = this.WGS2GCJ(poi);
|
if (typeof poi2 === "undefined") {
|
return;
|
}
|
//GCJ->百度坐标系
|
return this.GCJ2BD09(poi2);
|
}
|
|
function zhuanhuan(aaa) {
|
var c = new Convertor();
|
var bbb = [];
|
for (var i = 0; i < aaa.length; i++) {
|
var rr = c.WGS2BD09({ lng: aaa[i].lng, lat: aaa[i].lat });
|
bbb.push(rr);
|
}
|
return bbb;
|
c = null;
|
bbb = null;
|
}
|
|
</script>
|
</html>
|