From b284d078f196af80a105dc3bcb610d8ed37d9251 Mon Sep 17 00:00:00 2001 From: ZhuDongming <773644075@qq.com> Date: Fri, 08 Nov 2019 11:49:29 +0800 Subject: [PATCH] update --- src/main/webapp/view/pollutionsource.jsp | 460 +++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 312 insertions(+), 148 deletions(-) diff --git a/src/main/webapp/view/pollutionsource.jsp b/src/main/webapp/view/pollutionsource.jsp index c47f7ba..b9a9f7b 100644 --- a/src/main/webapp/view/pollutionsource.jsp +++ b/src/main/webapp/view/pollutionsource.jsp @@ -97,11 +97,33 @@ line-height: 100px; text-align: center; } + + #show { + position: absolute; + z-index: 1; + top: 30px; + right: 50px; + display: inline-block; + width: 100px; + height: 40px; + border-width: 0px; + border-radius: 3px; + background: #6495ED; + cursor: pointer; + outline: none; + color: white; + font-size: 20px; + } + + #show:hover { + background: #5CACEE; + } </style> <body> <div class="main_body"> - <div id="cpm">������������</div> + <input type="button" id="show" value="������������"/> + <div id="cpm">������������������</div> <div id="mapCanvas"></div> <!-- ������������ --> <!-- ���sensorInfo,regionCode,regionName,monitorPoint,device--> <div id="pollutionSourceParams" style="display: none;"> @@ -120,10 +142,8 @@ var params = $.parseJSON($("#pollutionSourceParams").html()); var month = params["month"]; var device = params["device"]; - var dirPoint=params["dirPoint"]; - console.log(dirPoint.lng); - console.log(dirPoint.lat); - var getPollutionSourceData=params["getPollutionSourceData"]; + var dirPoint = new BMap.Point(params["dirPoint"].lng, params["dirPoint"].lat); + var getPollutionSourceData = params["getPollutionSourceData"]; var map = new BMap.Map("mapCanvas", {enableMapClick: false}); map.setMapStyle(mapStyle); map.enableScrollWheelZoom(true); // ������������������������ @@ -133,139 +153,272 @@ }); map.addControl(navigation); map.addControl(new BMap.ScaleControl()); - if ($.isEmptyObject(dirPoint)||$.isEmptyObject(getPollutionSourceData)||getPollutionSourceData["e18"]==0) { - showNoData(); - }else{ - var humidity=getPollutionSourceData["e6"]; - var windSpeed=getPollutionSourceData["e18"]; - var longitude = params["device"]["longitude"]; - var latitude = params["device"]["latitude"]; - var point = new BMap.Point(longitude, latitude); - var icon = new BMap.Icon("/img/ico00.png", new BMap.Size(50, 50)); - var marker = new BMap.Marker(point, {icon: icon, offset: new BMap.Size(0, -20)}); - map.addOverlay(marker); - map.centerAndZoom(point, 17); - var polyline1 = new BMap.Polyline([ - dirPoint, - new BMap.Point(point.lng+0.01, point.lat+0.01) - ], - {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1} - ); - var polyline2 = new BMap.Polyline([ - dirPoint, - new BMap.Point( point.lng-0.02, point.lat-0.01) - ], - {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1} - ); - var distance=windSpeed*3600; - console.log(distance); - var arrowLength;//��������������������� - if (distance <= 5) { - arrowLength = 0; - } else if (distance > 5 && distance <= 20) { - arrowLength = 2; - } else if (distance > 20 && distance <= 50) { - arrowLength = 3; - } else if (distance > 50 && distance <= 100) { - arrowLength = 5; - } else if (distance > 100 && distance <= 200) { - arrowLength = 10; - } else if (distance > 200 && distance <= 500) { - arrowLength = 20; - } else if (distance > 500 && distance <= 1000) { - arrowLength = 40; - } else if (distance > 1000 && distance <= 2000) { - arrowLength = 80; - } else if (distance > 2000 && distance <= 3000) { - arrowLength = 120; - } else if (distance > 3000 && distance <= 10000) { - arrowLength = 500; - } else if (distance > 10000 && distance <= 20000) { - arrowLength = 1000; - } else if (distance > 20000 && distance <= 50000) { - arrowLength = 2500; - } else if (distance > 50000 && distance <= 100000) { - arrowLength = 5000; - } else if (distance > 100000 && distance <= 200000) { - arrowLength = 10000; - } else if (distance > 200000 && distance <= 500000) { - arrowLength = 25000; - } else if (distance > 500000 && distance <= 1000000) { - arrowLength = 50000; - } else if (distance > 1000000 && distance <= 2000000) { - arrowLength = 100000; - } else { - arrowLength = 150000; - } - map.addOverlay(polyline1);// ��������������� - addArrow(polyline1, arrowLength, Math.PI / 7,windSpeed); - map.addOverlay(polyline2);// ��������������� - addArrow(polyline2, arrowLength, Math.PI / 7,windSpeed); - var winfowTextCause = "<p style='height: 44px;line-height: 22px'>���������������������������������������������������������������������������������������������������������������������</p>"; - var winfowTextSource; - var supplement; - if (month == 12 || month == 1 || month == 2) { - if (windSpeed >= 3.4) { - supplement = "���������������������������������������������������������������������������"; - } - if (humidity>=90.0) { - supplement = "������������������������������������������������������������������������"; - }else{ - supplement =""; - } - winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������������������������" + supplement + "</p>"; - } else if (month == 3 || month == 4 || month == 5) { - if (windSpeed >= 3.4) { - supplement = "���������������������������������������������������������������������������"; - } - if (humidity>=90.0) { - supplement = "������������������������������������������������������������������������"; - }else{ - supplement =""; - } - winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������" + supplement + "</p>"; - } else if (month == 6 || month == 7) { - if (windSpeed >= 3.4) { - supplement = "������������������������������������"; - } - if (humidity>=90.0) { - supplement = "���������������������������������������������������������������������������"; - }else{ - supplement =""; - } - winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������,���������������������" + supplement + "</p>"; - } else if (month == 8 || month == 9 || month == 10 || month == 11) { - if (windSpeed >= 3.4) { - supplement = "������������������������������������������"; - } - if (humidity>=90.0) { - supplement = "������������������������������������������������������������������������"; - }else{ - supplement =""; - } - winfowTextSource = "<p style='height: 22px;line-height: 22px'>������������������������������������������������������������������������������������������������������" + supplement + "</p>"; - } - - var winfowText = '<div style="height:150px;" >'; - var opts = { - width: 380, - title: '<h3>������������</h3>', - enableMessage: false //��������������������������������� - } - winfowText += '<h3 style="background-color: #CD5C5C;color:white;margin-bottom: 1px">������������</h3>'; - winfowText += winfowTextCause; - winfowText += '<h3 style="background-color: #66CD00;color:white;margin-bottom: 1px">������������</h3>'; - winfowText += winfowTextSource; - winfowText += "</div>"; - marker.addEventListener("click", function () { - var infoWindow = new BMap.InfoWindow(winfowText, opts); - this.openInfoWindow(infoWindow); + var longitude = params["device"]["longitude"]; + var latitude = params["device"]["latitude"]; + var point = new BMap.Point(longitude, latitude); + var icon = new BMap.Icon("/img/ico00.png", new BMap.Size(50, 50)); + var icon1 = new BMap.Icon("/img/ico01.png", new BMap.Size(50, 50)); + var icon2 = new BMap.Icon("/img/ico02.png", new BMap.Size(50, 50)); + var marker = new BMap.Marker(point, {icon: icon, offset: new BMap.Size(0, -20)}); + map.addOverlay(marker); + map.centerAndZoom(point, 16); + if (!$.isEmptyObject(dirPoint) && !$.isEmptyObject(getPollutionSourceData) && typeof (getPollutionSourceData["e6"]) != "undefined" && typeof (getPollutionSourceData["e7"]) != "undefined" && typeof (getPollutionSourceData["e18"]) != "undefined" && typeof (getPollutionSourceData["e23"]) != "undefined") { + var windSpeed = parseFloat(getPollutionSourceData["e18"]); + var windDir = parseFloat(getPollutionSourceData["e23"]); + var distance = windSpeed * 3600>108? windSpeed * 3600:108; + var winDirStart = 255 - windDir; + var winDirEnd = 285 - windDir; + var marker1 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.15, winDirStart), { + icon: icon2, + offset: new BMap.Size(0, -20) }); + var marker2 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.31, winDirEnd), { + icon: icon2, + offset: new BMap.Size(0, -20) + }); + var marker3 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.61, winDirStart), { + icon: icon1, + offset: new BMap.Size(0, -20) + }); + var marker4 = new BMap.Marker(EOffsetBearing(dirPoint, distance * 0.78, winDirEnd), { + icon: icon1, + offset: new BMap.Size(0, -20) + }); + map.addOverlay(marker1); + map.addOverlay(marker2); + map.addOverlay(marker3); + map.addOverlay(marker4); } + $("#show").one('click', function () { + setTimeout(function () { + if ($.isEmptyObject(dirPoint) || $.isEmptyObject(getPollutionSourceData) || typeof (getPollutionSourceData["e6"]) == "undefined" || typeof (getPollutionSourceData["e7"]) == "undefined" || typeof (getPollutionSourceData["e18"]) == "undefined" || typeof (getPollutionSourceData["e23"]) == "undefined") { + showNoData(); + } else { + var humidity = parseFloat(getPollutionSourceData["e6"]); + var temperature = parseFloat(getPollutionSourceData["e7"]); + var windSpeed = parseFloat(getPollutionSourceData["e18"]); + var windDir = parseFloat(getPollutionSourceData["e23"]); + var selectSensorKey = getPollutionSourceData["selectSensorKey"]; + var markerDir = new BMap.Marker(dirPoint); + lab = new BMap.Label("���������������������������������������������</br>" + selectSensorKey + "������", { + position: dirPoint, + offset: new BMap.Size(20, -40) + }); + lab.setStyle({ + color: "#EE3B3B", + fontSize: "16px", + backgroundColor: "1", + fontWeight: "bold" + }); + map.addOverlay(lab); + var distance = windSpeed * 3600>108? windSpeed * 3600:108; + var winDirStartLeft = 240 - windDir; + var winDirEndLeft = 250 - windDir; + var winDirStartMiddle = 250 - windDir; + var winDirEndMiddle = 290 - windDir; + var winDirStartRight = 290 - windDir; + var winDirEndRight = 300 - windDir; + var winDirStart = 255 - windDir; + var winDirEnd = 285 - windDir; + var polyline1 = new BMap.Polyline([ + dirPoint, + EOffsetBearing(dirPoint, distance, winDirStart) + ], + {strokeColor: "red", strokeWeight: 4, strokeOpacity: 1} + ); + var polyline2 = new BMap.Polyline([ + dirPoint, + EOffsetBearing(dirPoint, distance, winDirEnd) + ], + {strokeColor: "red", strokeWeight: 4, strokeOpacity: 1} + ); + map.addOverlay(polyline1);// ��������������� + map.addOverlay(polyline2);// ��������������� + map.addOverlay(markerDir); + setTimeout(function () { + var ovalLeft = new BMap.Polygon(Sector(dirPoint, distance, winDirStartLeft, winDirEndLeft), { + strokeColor: "#ADADAD", + strokeWeight: 0.1, + strokeOpacity: 0.7, + fillColor: "#ADADAD" + }); + map.addOverlay(ovalLeft); + var oval = new BMap.Polygon(Sector(dirPoint, distance, winDirStartMiddle, winDirEndMiddle), { + strokeColor: "#A6A6A6", + strokeWeight: 0.1, + strokeOpacity: 0.95, + fillColor: "#A6A6A6" + }); + map.addOverlay(oval); + var ovalRight = new BMap.Polygon(Sector(dirPoint, distance, winDirStartRight, winDirEndRight), { + strokeColor: "#ADADAD", + strokeWeight: 0.1, + strokeOpacity: 0.7, + fillColor: "#ADADAD" + }); + map.addOverlay(ovalRight); + }, 1500); + setTimeout(function () { + var ovalLeft = new BMap.Polygon(Sector(dirPoint, distance * 0.66, winDirStartLeft, winDirEndLeft), { + strokeColor: "#ADADAD", + strokeWeight: 0.1, + strokeOpacity: 0.5, + fillColor: "#ADADAD" + }); + map.addOverlay(ovalLeft); + var oval = new BMap.Polygon(Sector(dirPoint, distance * 0.66, winDirStartMiddle, winDirEndMiddle), { + strokeColor: "#A6A6A6", + strokeWeight: 0.1, + strokeOpacity: 0.75, + fillColor: "#A6A6A6" + }); + map.addOverlay(oval); + var ovalRight = new BMap.Polygon(Sector(dirPoint, distance * 0.66, winDirStartRight, winDirEndRight), { + strokeColor: "#ADADAD", + strokeWeight: 0.1, + strokeOpacity: 0.7, + fillColor: "#ADADAD" + }); + map.addOverlay(ovalRight); + var polyline = new BMap.Polyline([ + dirPoint, + point + ], + {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1} + ); + addArrow(polyline, 0, Math.PI / 7, temperature, humidity, windSpeed, windDir); + }, 1000); + setTimeout(function () { + var ovalLeft = new BMap.Polygon(Sector(dirPoint, distance * 0.33, winDirStartLeft, winDirEndLeft), { + strokeColor: "#ADADAD", + strokeWeight: 0.1, + strokeOpacity: 0.3, + fillColor: "#ADADAD" + }); + map.addOverlay(ovalLeft); + var oval = new BMap.Polygon(Sector(dirPoint, distance * 0.33, winDirStartMiddle, winDirEndMiddle), { + strokeColor: "#A6A6A6", + strokeWeight: 0.1, + strokeOpacity: 0.55, + fillColor: "#A6A6A6" + }); + var ovalRight = new BMap.Polygon(Sector(dirPoint, distance * 0.33, winDirStartRight, winDirEndRight), { + strokeColor: "#ADADAD", + strokeWeight: 0.1, + strokeOpacity: 0.7, + fillColor: "#ADADAD" + }); + map.addOverlay(ovalRight); + map.addOverlay(oval); + }, 500); - function addArrow(polyline, length, angleValue,windSpeed) { + var winfowTextCause = "<p style='height: 22px;line-height: 22px'>������������������������������������������������������������������</p>"; + var winfowTextSource; + var supplement; + if (selectSensorKey == "������") { + winfowTextCause = "<p style='height: 44px;line-height: 22px'>���������������������������������������������������������������������������������������������������������������������������������������������</p>"; + winfowTextSource = "<p style='height: 22px;line-height: 22px'>NOx������VOCs������������</p>"; + } else { + if (month == 12 || month == 1 || month == 2) { + if (windSpeed >= 3.4) { + supplement = "���������������������������������������������������������������������������"; + } + if (humidity >= 90.0) { + supplement = "������������������������������������������������������������������������"; + } else { + supplement = ""; + } + winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������������������������" + supplement + "</p>"; + } else if (month == 3 || month == 4 || month == 5) { + if (windSpeed >= 3.4) { + supplement = "���������������������������������������������������������������������������"; + } + if (humidity >= 90.0) { + supplement = "������������������������������������������������������������������������"; + } else { + supplement = ""; + } + winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������������������������������" + supplement + "</p>"; + } else if (month == 6 || month == 7) { + if (windSpeed >= 3.4) { + supplement = "������������������������������������"; + } + if (humidity >= 90.0) { + supplement = "���������������������������������������������������������������������������"; + } else { + supplement = ""; + } + winfowTextSource = "<p style='height: 22px;line-height: 22px'>���������������������������������������,���������������������" + supplement + "</p>"; + } else if (month == 8 || month == 9 || month == 10 || month == 11) { + if (windSpeed >= 3.4) { + supplement = "������������������������������������������"; + } + if (humidity >= 90.0) { + supplement = "������������������������������������������������������������������������"; + } else { + supplement = ""; + } + winfowTextSource = "<p style='height: 22px;line-height: 22px'>������������������������������������������������������������������������������������������������������" + supplement + "</p>"; + } + } + + var winfowText = '<div style="height:150px;" >'; + var opts = { + width: 380, + title: '<h3>������������</h3>', + enableMessage: false //��������������������������������� + } + winfowText += '<h3 style="background-color: #CD5C5C;color:white;margin-bottom: 1px">������������</h3>'; + winfowText += winfowTextCause; + winfowText += '<h3 style="background-color: #66CD00;color:white;margin-bottom: 1px">������������</h3>'; + winfowText += winfowTextSource; + winfowText += "</div>"; + marker.addEventListener("click", function () { + var infoWindow = new BMap.InfoWindow(winfowText, opts); + this.openInfoWindow(infoWindow); + }); + } + }, 1500); + }); + + //centre:���������������,X:������������,Y:������������ + function add_oval(centre, x, y) { + var assemble = new Array(); + var angle; + var dot; + var tangent = x / y; + for (i = 0; i < 36; i++) { + angle = (2 * Math.PI / 36) * i; + dot = new BMap.Point(centre.lng + Math.sin(angle) * y * tangent, centre.lat + Math.cos(angle) * y); + assemble.push(dot); + } + return assemble; + } + + //��������������������������������������������� ���������point������������������������radius������������sDegree���eDegree��������� + function Sector(point, radius, sDegree, eDegree) { + var points = []; //��������������������������������� + var step = ((eDegree - sDegree) / 100) || 1; //������������������������������������������������������������10 + points.push(point); + for (var i = sDegree; i < eDegree + 0.001; i += step) { //������������������������������������������������������������ + points.push(EOffsetBearing(point, radius, i)); + } + points.push(point); + return points; + } + + //������������������������������������������������������������������ + function EOffsetBearing(point, dist, bearing) { + var lngConv = map.getDistance(point, new BMap.Point(point.lng + 0.1, point.lat)) * 10; //������������������������������ + var latConv = map.getDistance(point, new BMap.Point(point.lng, point.lat + 0.1)) * 10; //������������������������������ + var lat = dist * Math.sin(bearing * Math.PI / 180) / latConv; //������������������������������������������������������ + var lng = dist * Math.cos(bearing * Math.PI / 180) / lngConv; //������������������������������������������������������ + return new BMap.Point(point.lng + lng, point.lat + lat); + } + + function addArrow(polyline, length, angleValue, temperature, humidity, windSpeed, windDir) { var linePoint = polyline.getPath();// ��������������� var arrowCount = linePoint.length; for (var i = 1; i < arrowCount; i++) { // ������������������������ @@ -276,7 +429,7 @@ var delta = 0; // ��������������������������������� var param = 0; // ������������������ var pixelTemX, pixelTemY, poMiddleX, poMiddleY;// ��������������� - var pixelX, pixelY, pixelX1, pixelY1;// ��������������� + var pixelX, pixelY;// ��������������� poMiddleX = (pixelEnd.x + pixelStart.x) / 2; poMiddleY = (pixelEnd.y + pixelStart.y) / 2; if (poMiddleX - pixelStart.x == 0) { // ������������������ @@ -288,8 +441,7 @@ } // ��������������������������������������������������������������������������������������� pixelX = pixelTemX - r * Math.tan(angle); - pixelX1 = pixelTemX + r * Math.tan(angle); - pixelY = pixelY1 = pixelTemY; + pixelY = pixelTemY; } else { // ��������������� delta = (poMiddleY - pixelStart.y) / (poMiddleX - pixelStart.x); param = Math.sqrt(delta * delta + 1); @@ -303,34 +455,46 @@ // ��������������������������������������������������������������������������������������� pixelX = pixelTemX + Math.tan(angle) * r * delta / param; pixelY = pixelTemY - Math.tan(angle) * r / param; - pixelX1 = pixelTemX - Math.tan(angle) * r * delta / param; - pixelY1 = pixelTemY + Math.tan(angle) * r / param; } - var pointArrow = map.pixelToPoint(new BMap.Pixel(pixelX, pixelY)); - var pointArrow1 = map.pixelToPoint(new BMap.Pixel(pixelX1, pixelY1)); var pointMiddle = map.pixelToPoint(new BMap.Pixel(poMiddleX, poMiddleY)); - lab = new BMap.Label("���������"+windSpeed+"m/s", {position: pointMiddle, offset: new BMap.Size(0, -30)}); + var windDirection; + if (windDir == 0) { + windDirection = "������"; + } else if (windDir == 90) { + windDirection = "������"; + } else if (windDir == 180) { + windDirection = "������"; + } else if (windDir == 270) { + windDirection = "������"; + } else if (windDir > 0 && windDir < 90) { + windDirection = "���������"; + } else if (windDir > 90 && windDir < 180) { + windDirection = "���������"; + } else if (windDir > 180 && windDir < 270) { + windDirection = "���������"; + } else if (windDir > 270 && windDir < 360) { + windDirection = "���������"; + } + lab = new BMap.Label("<P>������:" + temperature + "���</p><P>������:" + humidity + "%</p><P>������:" + windSpeed + "m/s</p><P>������:" + windDirection + "</p>", { + position: pointMiddle, + offset: new BMap.Size(-50, -40) + }); lab.setStyle({ - color: "red", + color: "#EE3B3B", fontSize: "16px", backgroundColor: "1", border: "0", fontWeight: "bold" }); map.addOverlay(lab); - var Arrow = new BMap.Polyline([pointArrow, pointMiddle, pointArrow1], - {strokeColor: "#5298FF", strokeWeight: 4, strokeOpacity: 1}); - map.addOverlay(Arrow); } }; function showNoData() { - var longitude = 120.987287; - var latitude = 31.391562; - var point = new BMap.Point(longitude, latitude); map.centerAndZoom(point, 17); setTimeout(function () { document.getElementById("cpm").style.display = 'block'; }, 250); }; + </script> -- Gitblit v1.8.0