From 11f6acee504c77a8919a4e0ddfe3e70a746e3522 Mon Sep 17 00:00:00 2001 From: fei.wang <wf18701153496@163.com> Date: 星期五, 18 四月 2025 17:39:33 +0800 Subject: [PATCH] 4.18更新v2.1.5 --- src/views/dpdv/map.vue | 610 +++++++++++++++++++++++++++--------------------------- 1 files changed, 304 insertions(+), 306 deletions(-) diff --git a/src/views/dpdv/map.vue b/src/views/dpdv/map.vue index ec26740..8b157ba 100644 --- a/src/views/dpdv/map.vue +++ b/src/views/dpdv/map.vue @@ -464,6 +464,9 @@ tdmm: "绠$悊鍛�", gpsnum: "", }; +let markers = []; +let addedCarIds = new Set(); +let gaddedCarIds = new Set(); var map; var markerg; var labelg; @@ -536,10 +539,6 @@ phone: localStorage.getItem("phone"), }; alldevice(params).then((response) => { - console.log(111111111); - - console.log(response); - this.initMap( response.data.gbList, response.data.dataList, @@ -550,9 +549,6 @@ }, methods: { change(e) { - console.log(333333333); - - console.log(e); var state = ""; if (e == true) { state = "ON"; @@ -563,10 +559,6 @@ const params = { status: state, tagid: this.tagid }; startorstop(params).then((response) => { - console.log(111111111); - - console.log(response); - // this.initMap(response.data.gbList, response.data.dataList, response.data.view, response.data.shijiao) }); }, @@ -582,92 +574,92 @@ guangbopoint(gaungbo) { let zxguangbo = new BMapGL.Icon(zguangbo, new BMapGL.Size(30, 30)); let lxguangbo = new BMapGL.Icon(lguangbo, new BMapGL.Size(30, 30)); - // let onliezhan = new BMapGL.Icon(onlie, new BMapGL.Size(30, 30)) + this.removePreviousMarkers(); for (let i = 0; i < gaungbo.length; i++) { if (gaungbo[i].center != null && gaungbo[i].center != "") { - if ( - gaungbo[i].center.split(";")[0].toString().length > 5 && - gaungbo[i].center.split(";")[0].toString().length > 4 - ) { - markerg; - labelg = new BMapGL.Label(gaungbo[i].name + " " + gaungbo[i].tagid, { - offset: new BMapGL.Size(0, -40), - }); - console.log(222222222); + + if ( + gaungbo[i].center.split(";")[0].toString().length > 5 && + gaungbo[i].center.split(";")[0].toString().length > 4 + ) { + markerg; + labelg = new BMapGL.Label(gaungbo[i].name + " " + gaungbo[i].tagid, { + offset: new BMapGL.Size(0, -40), + }); + if (gaungbo[i].state == 1) { + // var rr = c.WGS2BD09({ + // lng: new Number(ToDigital(gaungbo[i].center.split(";")[0].substring(0, 3), gaungbo[i].center.split(";")[0].substring(3, 5), gaungbo[i].center.split(";")[0].substring(5))), + // lat: new Number(ToDigital(gaungbo[i].center.split(";")[1].substring(0, 2),gaungbo[i].center.split(";")[1].substring(2, 4),gaungbo[i].center.split(";")[1].substring(4))) + // }); + var rr = c.WGS2BD09({ + lng: new Number(), + lat: new Number(gaungbo[i].center.split(";")[1]), + }); + var pt = new BMapGL.Point( + gaungbo[i].center.split(";")[0], + gaungbo[i].center.split(";")[1] + ); + markerg = new BMapGL.Marker(pt, { + icon: zxguangbo, + }); + labelg.setStyle({ + color: "#fff", + fontSize: "14px", + borderRadius: "5px", + padding: "5px 5px", + border: "0", + backgroundColor: "#fa770b", + transform: "translateX(-50%)", + }); + } else { + // var rr = c.WGS2BD09({ + // lng: new Number(ToDigital(gaungbo[i].center.split(";")[0].substring(0, 3), gaungbo[i].center.split(";")[0].substring(3, 5),gaungbo[i].center.split(";")[0].substring(5))), + // lat: new Number(ToDigital(gaungbo[i].center.split(";")[1].substring(0, 2), gaungbo[i].center.split(";")[1].substring(2, 4), gaungbo[i].center.split(";")[1].substring(4))) + // }); - console.log(gaungbo[i]); - console.log(444444444); - if (gaungbo[i].state == 1) { - // var rr = c.WGS2BD09({ - // lng: new Number(ToDigital(gaungbo[i].center.split(";")[0].substring(0, 3), gaungbo[i].center.split(";")[0].substring(3, 5), gaungbo[i].center.split(";")[0].substring(5))), - // lat: new Number(ToDigital(gaungbo[i].center.split(";")[1].substring(0, 2),gaungbo[i].center.split(";")[1].substring(2, 4),gaungbo[i].center.split(";")[1].substring(4))) - // }); - var rr = c.WGS2BD09({ - lng: new Number(), - lat: new Number(gaungbo[i].center.split(";")[1]), - }); - var pt = new BMapGL.Point( - gaungbo[i].center.split(";")[0], - gaungbo[i].center.split(";")[1] - ); - markerg = new BMapGL.Marker(pt, { - icon: zxguangbo, - }); - labelg.setStyle({ - color: "#fff", - fontSize: "14px", - borderRadius: "5px", - padding: "5px 5px", - border: "0", - backgroundColor: "#fa770b", - transform: "translateX(-50%)", - }); - } else { - // var rr = c.WGS2BD09({ - // lng: new Number(ToDigital(gaungbo[i].center.split(";")[0].substring(0, 3), gaungbo[i].center.split(";")[0].substring(3, 5),gaungbo[i].center.split(";")[0].substring(5))), - // lat: new Number(ToDigital(gaungbo[i].center.split(";")[1].substring(0, 2), gaungbo[i].center.split(";")[1].substring(2, 4), gaungbo[i].center.split(";")[1].substring(4))) - // }); + // var rr = c.WGS2BD09({ + // lng: new Number(gaungbo[i].center.split(";")[0]), + // lat: new Number(gaungbo[i].center.split(";")[1]) + // }); + var pt = new BMapGL.Point( + gaungbo[i].center.split(";")[0], + gaungbo[i].center.split(";")[1] + ); + // var pt = new BMapGL.Point(rr.lng, rr.lat) + markerg = new BMapGL.Marker(pt, { + icon: lxguangbo, + }); + labelg.setStyle({ + color: "#fff", + fontSize: "14px", + borderRadius: "5px", + padding: "5px 5px", + border: "0", + backgroundColor: "#474747", + transform: "translateX(-50%)", + }); + } - // var rr = c.WGS2BD09({ - // lng: new Number(gaungbo[i].center.split(";")[0]), - // lat: new Number(gaungbo[i].center.split(";")[1]) - // }); - var pt = new BMapGL.Point( - gaungbo[i].center.split(";")[0], - gaungbo[i].center.split(";")[1] - ); - // var pt = new BMapGL.Point(rr.lng, rr.lat) - markerg = new BMapGL.Marker(pt, { - icon: lxguangbo, + markerg.addEventListener("click", () => { + this.tagid = gaungbo[i].tagid; + // var params = { tagid: gaungbo[i].tagid } + // getdevicestate(params).then(response => { + // this.tagid = response.data.dataList.tagid + this.name = gaungbo[i].name; + this.state = gaungbo[i].state; + this.addtime = gaungbo[i].addtime; + this.relayone = gaungbo[i].relayone == 0 ? false : true; + // }) + + // tagid.value = tags[i].tagid + this.centerdialogVisiblegb = true; }); - labelg.setStyle({ - color: "#fff", - fontSize: "14px", - borderRadius: "5px", - padding: "5px 5px", - border: "0", - backgroundColor: "#474747", - transform: "translateX(-50%)", - }); + markerg.setLabel(labelg); + map.addOverlay(markerg); + gaddedCarIds.add(gaungbo[i].id); + markers.push(markerg); } - - markerg.addEventListener("click", () => { - this.tagid = gaungbo[i].tagid; - // var params = { tagid: gaungbo[i].tagid } - // getdevicestate(params).then(response => { - // this.tagid = response.data.dataList.tagid - this.name = gaungbo[i].name; - this.state = gaungbo[i].state; - this.addtime = gaungbo[i].addtime; - this.relayone = gaungbo[i].relayone == 0 ? false : true; - // }) - - // tagid.value = tags[i].tagid - this.centerdialogVisiblegb = true; - }); - markerg.setLabel(labelg); - map.addOverlay(markerg); - } + } } @@ -677,20 +669,29 @@ phone: localStorage.getItem("phone"), }; alldevice(params).then((response) => { - console.log(111111111); - - console.log(response); this.guangbopoint(response.data.gbList); // this.initMap(response.data.gbList, response.data.dataList, response.data.view, response.data.shijiao) }); }, 5000); }, + + // 瀛樺偍鎵�鏈夋坊鍔犲埌鍦板浘涓婄殑鏍囪鐗� + + +// 鍒犻櫎涓婁竴娆℃坊鍔犵殑鎵�鏈夋爣璁扮墿 + removePreviousMarkers() { + markers.forEach(marker => { + map.removeOverlay(marker); + map.removeOverlay(markerg); + }); + markers = []; +}, pointdata(tags) { let jizhunzhan = new BMapGL.Icon(jizhun, new BMapGL.Size(30, 30)); let jiancezhan = new BMapGL.Icon(jiance, new BMapGL.Size(30, 30)); let onliezhan = new BMapGL.Icon(onlie, new BMapGL.Size(30, 30)); let gjimg = new BMapGL.Icon(gjimage, new BMapGL.Size(30, 30)); - + this.removePreviousMarkers(); for (let i = 0; i < tags.length; i++) { if ( tags[i].lon != null && @@ -699,214 +700,216 @@ tags[i].lat != "" ) { if (tags[i].lon.toString().length > 5 && tags[i].lat.toString().length > 4) { - marker; - label = new BMapGL.Label(tags[i].anchorname + " " + tags[i].tagid, { - offset: new BMapGL.Size(0, -40), - }); - console.log(tags[i]); - - if (tags[i].type == 0) { - if (tags[i].onlie == 1 || tags[i].onlie == 4) { - var rr = c.WGS2BD09({ - lng: new Number( - ToDigital( - tags[i].lon.substring(0, 3), - tags[i].lon.substring(3, 5), - tags[i].lon.substring(5) - ) - ), - lat: new Number( - ToDigital( - tags[i].lat.substring(0, 2), - tags[i].lat.substring(2, 4), - tags[i].lat.substring(4) - ) - ), - }); - var pt = new BMapGL.Point(rr.lng, rr.lat); - marker = new BMapGL.Marker(pt, { - icon: jizhunzhan, - }); - label.setStyle({ - color: "#fff", - fontSize: "14px", - borderRadius: "5px", - padding: "5px 5px", - border: "0", - backgroundColor: "#fa770b", - transform: "translateX(-50%)", - }); - } else if (tags[i].onlie == 6 || tags[i].onlie == 7) { - var rr = c.WGS2BD09({ - lng: new Number( - ToDigital( - tags[i].lon.substring(0, 3), - tags[i].lon.substring(3, 5), - tags[i].lon.substring(5) - ) - ), - lat: new Number( - ToDigital( - tags[i].lat.substring(0, 2), - tags[i].lat.substring(2, 4), - tags[i].lat.substring(4) - ) - ), - }); - var pt = new BMapGL.Point(rr.lng, rr.lat); - marker = new BMapGL.Marker(pt, { - icon: gjimg - }); - label.setStyle({ - color: "#fff", - fontSize: "14px", - borderRadius: "5px", - padding: "5px 5px", - border: "0", - backgroundColor: "#fa770b", - transform: "translateX(-50%)", - }); - } else { - var rr = c.WGS2BD09({ - lng: new Number( - ToDigital( - tags[i].lon.substring(0, 3), - tags[i].lon.substring(3, 5), - tags[i].lon.substring(5) - ) - ), - lat: new Number( - ToDigital( - tags[i].lat.substring(0, 2), - tags[i].lat.substring(2, 4), - tags[i].lat.substring(4) - ) - ), - }); - var pt = new BMapGL.Point(rr.lng, rr.lat); - marker = new BMapGL.Marker(pt, { - icon: onliezhan, - }); - label.setStyle({ - color: "#fff", - fontSize: "14px", - borderRadius: "5px", - padding: "5px 5px", - border: "0", - backgroundColor: "#474747", - transform: "translateX(-50%)", - }); - } - } else { - if (tags[i].onlie == 1 || tags[i].onlie == 4) { - var rr = c.WGS2BD09({ - lng: new Number( - ToDigital( - tags[i].lon.substring(0, 3), - tags[i].lon.substring(3, 5), - tags[i].lon.substring(5) - ) - ), - lat: new Number( - ToDigital( - tags[i].lat.substring(0, 2), - tags[i].lat.substring(2, 4), - tags[i].lat.substring(4) - ) - ), - }); - var pt = new BMapGL.Point(rr.lng, rr.lat); - marker = new BMapGL.Marker(pt, { - icon: jiancezhan, - }); - label.setStyle({ - color: "#fff", - fontSize: "14px", - borderRadius: "5px", - padding: "5px 5px", - border: "0", - backgroundColor: "#32CD32", - transform: "translateX(-50%)", - }); - } else if (tags[i].onlie == 6 || tags[i].onlie == 7) { - var rr = c.WGS2BD09({ - lng: new Number( - ToDigital( - tags[i].lon.substring(0, 3), - tags[i].lon.substring(3, 5), - tags[i].lon.substring(5) - ) - ), - lat: new Number( - ToDigital( - tags[i].lat.substring(0, 2), - tags[i].lat.substring(2, 4), - tags[i].lat.substring(4) - ) - ), - }); - var pt = new BMapGL.Point(rr.lng, rr.lat); - marker = new BMapGL.Marker(pt, { - icon: gjimg, - }); - label.setStyle({ - color: "#fff", - fontSize: "14px", - borderRadius: "5px", - padding: "5px 5px", - border: "0", - backgroundColor: "#fa770b", - transform: "translateX(-50%)", - }); - } else { - var rr = c.WGS2BD09({ - lng: new Number( - ToDigital( - tags[i].lon.substring(0, 3), - tags[i].lon.substring(3, 5), - tags[i].lon.substring(5) - ) - ), - lat: new Number( - ToDigital( - tags[i].lat.substring(0, 2), - tags[i].lat.substring(2, 4), - tags[i].lat.substring(4) - ) - ), - }); - var pt = new BMapGL.Point(rr.lng, rr.lat); - marker = new BMapGL.Marker(pt, { - icon: onliezhan, - }); - label.setStyle({ - color: "#fff", - fontSize: "14px", - borderRadius: "5px", - padding: "5px 5px", - border: "0", - backgroundColor: "#474747", - transform: "translateX(-50%)", - }); - } - } - marker.addEventListener("click", () => { - this.tagid = tags[i].tagid; - var params = { tagid: tags[i].tagid }; - getdevicestate(params).then((response) => { - this.edm = response.data.dataList.edmm + "mm"; - this.ndm = response.data.dataList.ndmm + "mm"; - this.hdm = response.data.dataList.tdmm + "mm"; - this.power = response.data.dataList2.electricity; - this.gpsnum = response.data.dataList2.gpsnum; - this.gpsstate = response.data.dataList2.gpsstate; + marker; + + label = new BMapGL.Label(tags[i].anchorname + " " + tags[i].tagid, { + offset: new BMapGL.Size(0, -40), }); - // tagid.value = tags[i].tagid - this.centerdialogVisible = true; - }); - marker.setLabel(label); - map.addOverlay(marker); + if (tags[i].type == 0) { + if (tags[i].onlie == 1 || tags[i].onlie == 4) { + var rr = c.WGS2BD09({ + lng: new Number( + ToDigital( + tags[i].lon.substring(0, 3), + tags[i].lon.substring(3, 5), + tags[i].lon.substring(5) + ) + ), + lat: new Number( + ToDigital( + tags[i].lat.substring(0, 2), + tags[i].lat.substring(2, 4), + tags[i].lat.substring(4) + ) + ), + }); + var pt = new BMapGL.Point(rr.lng, rr.lat); + marker = new BMapGL.Marker(pt, { + icon: jizhunzhan, + }); + label.setStyle({ + color: "#fff", + fontSize: "14px", + borderRadius: "5px", + padding: "5px 5px", + border: "0", + backgroundColor: "#fa770b", + transform: "translateX(-50%)", + }); + } else if (tags[i].onlie == 6 || tags[i].onlie == 7) { + var rr = c.WGS2BD09({ + lng: new Number( + ToDigital( + tags[i].lon.substring(0, 3), + tags[i].lon.substring(3, 5), + tags[i].lon.substring(5) + ) + ), + lat: new Number( + ToDigital( + tags[i].lat.substring(0, 2), + tags[i].lat.substring(2, 4), + tags[i].lat.substring(4) + ) + ), + }); + var pt = new BMapGL.Point(rr.lng, rr.lat); + marker = new BMapGL.Marker(pt, { + icon: gjimg, + }); + label.setStyle({ + color: "#fff", + fontSize: "14px", + borderRadius: "5px", + padding: "5px 5px", + border: "0", + backgroundColor: "#fa770b", + transform: "translateX(-50%)", + }); + } else { + var rr = c.WGS2BD09({ + lng: new Number( + ToDigital( + tags[i].lon.substring(0, 3), + tags[i].lon.substring(3, 5), + tags[i].lon.substring(5) + ) + ), + lat: new Number( + ToDigital( + tags[i].lat.substring(0, 2), + tags[i].lat.substring(2, 4), + tags[i].lat.substring(4) + ) + ), + }); + var pt = new BMapGL.Point(rr.lng, rr.lat); + marker = new BMapGL.Marker(pt, { + icon: onliezhan, + }); + label.setStyle({ + color: "#fff", + fontSize: "14px", + borderRadius: "5px", + padding: "5px 5px", + border: "0", + backgroundColor: "#474747", + transform: "translateX(-50%)", + }); + } + } else { + if (tags[i].onlie == 1 || tags[i].onlie == 4) { + var rr = c.WGS2BD09({ + lng: new Number( + ToDigital( + tags[i].lon.substring(0, 3), + tags[i].lon.substring(3, 5), + tags[i].lon.substring(5) + ) + ), + lat: new Number( + ToDigital( + tags[i].lat.substring(0, 2), + tags[i].lat.substring(2, 4), + tags[i].lat.substring(4) + ) + ), + }); + var pt = new BMapGL.Point(rr.lng, rr.lat); + marker = new BMapGL.Marker(pt, { + icon: jiancezhan, + }); + label.setStyle({ + color: "#fff", + fontSize: "14px", + borderRadius: "5px", + padding: "5px 5px", + border: "0", + backgroundColor: "#32CD32", + transform: "translateX(-50%)", + }); + } else if (tags[i].onlie == 6 || tags[i].onlie == 7) { + var rr = c.WGS2BD09({ + lng: new Number( + ToDigital( + tags[i].lon.substring(0, 3), + tags[i].lon.substring(3, 5), + tags[i].lon.substring(5) + ) + ), + lat: new Number( + ToDigital( + tags[i].lat.substring(0, 2), + tags[i].lat.substring(2, 4), + tags[i].lat.substring(4) + ) + ), + }); + var pt = new BMapGL.Point(rr.lng, rr.lat); + marker = new BMapGL.Marker(pt, { + icon: gjimg, + }); + label.setStyle({ + color: "#fff", + fontSize: "14px", + borderRadius: "5px", + padding: "5px 5px", + border: "0", + backgroundColor: "#fa770b", + transform: "translateX(-50%)", + }); + } else { + var rr = c.WGS2BD09({ + lng: new Number( + ToDigital( + tags[i].lon.substring(0, 3), + tags[i].lon.substring(3, 5), + tags[i].lon.substring(5) + ) + ), + lat: new Number( + ToDigital( + tags[i].lat.substring(0, 2), + tags[i].lat.substring(2, 4), + tags[i].lat.substring(4) + ) + ), + }); + var pt = new BMapGL.Point(rr.lng, rr.lat); + marker = new BMapGL.Marker(pt, { + icon: onliezhan, + }); + label.setStyle({ + color: "#fff", + fontSize: "14px", + borderRadius: "5px", + padding: "5px 5px", + border: "0", + backgroundColor: "#474747", + transform: "translateX(-50%)", + }); + } + } + marker.addEventListener("click", () => { + this.tagid = tags[i].tagid; + var params = { tagid: tags[i].tagid }; + getdevicestate(params).then((response) => { + this.edm = response.data.dataList.edmm + "mm"; + this.ndm = response.data.dataList.ndmm + "mm"; + this.hdm = response.data.dataList.tdmm + "mm"; + this.power = response.data.dataList2.electricity; + this.gpsnum = response.data.dataList2.gpsnum; + this.gpsstate = response.data.dataList2.gpsstate; + }); + + // tagid.value = tags[i].tagid + this.centerdialogVisible = true; + }); + marker.setLabel(label); + map.addOverlay(marker); + addedCarIds.add(tags[i].id); + markers.push(marker); } } } @@ -917,9 +920,6 @@ phone: localStorage.getItem("phone"), }; alldevice(params).then((response) => { - console.log(111111111); - - console.log(response); this.pointdata(response.data.dataList); // this.initMap(response.data.gbList, response.data.dataList, response.data.view, response.data.shijiao) }); @@ -927,8 +927,6 @@ }, initMap(gaungbo, tags, view, shijiao) { - console.log(shijiao); - // $(window).scrollTop(0); // window.scroll(0, 0); var c = new Convertor(); -- Gitblit v1.9.3