From 90a6386cda8e3356c23f283656bf94e21e94b46a Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Thu, 08 Aug 2019 17:02:41 +0800
Subject: [PATCH] 修改路线粗细颜色及显示因子单位

---
 src/main/webapp/js/moralmap.js |  149 ++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 122 insertions(+), 27 deletions(-)

diff --git a/src/main/webapp/js/moralmap.js b/src/main/webapp/js/moralmap.js
index f097d2b..313ae6e 100644
--- a/src/main/webapp/js/moralmap.js
+++ b/src/main/webapp/js/moralmap.js
@@ -508,7 +508,8 @@
 		function _getMapIcon(state) {
 			state = state == null ? 0 : state;
 			var icon = _option["icon"];
-			var url = icon["stateIcons"][state];
+			//var url = icon["stateIcons"][state];
+			var url = icon["url"] + state + ".png";
 			return new BMap.Icon(url, new BMap.Size(icon["width"], icon["height"]), {
 				imageSize: new BMap.Size(icon["width"], icon["height"])
 			});
@@ -550,10 +551,18 @@
 	//new BMap.Marker()������������IE7���������������������
 	moralMap.MoralMarker.prototype = new BMap.Marker();
 	//��������������� ������Mark������
-	var showMonitorpointInfoWindow = null;
 	moralMap.Monitorpoint = function(option) {
+		if(monitorPointStates){
+			for(var i in monitorPointStates){
+		    	var state = monitorPointStates[i];
+		    	if(state.id == option.id){
+		    		option.state = state.state;
+		    	}
+			}
+		}
 		var icon = {};
 		icon["stateIcons"] = ["/img/ico00.png", "/img/ico01.png", "/img/ico02.png", "/img/ico03.png", "/img/ico04.png"];
+		icon["url"] = "/img/ico0";
 		icon["width"] = 50;
 		icon["height"] = 50;
 		option["icon"] = icon;
@@ -600,9 +609,6 @@
 			}
 			return new BMap.InfoWindow(getAdressOutHtml(), winOpts);
 		})();
-		if (!showMonitorpointInfoWindow) {
-			showMonitorpointInfoWindow = infoWindow;
-		}
 		if(moralMarker["infoWindow"] == undefined) {
 			moralMarker["infoWindow"] = infoWindow;
 		}
@@ -642,10 +648,18 @@
 	}
 	//���������mac���key������
 	//��������������� ������MoralMark������
-	var showEquipmentInfoWindow = null;
 	moralMap.Equipment = function(option) {
+		if(deviceStates){
+			for(var i in deviceStates){
+		    	var state = deviceStates[i];
+		    	if(state.id == option.id){
+		    		option.state = state.state;
+		    	}
+			}
+		}
 		var icon = {};
 		icon["stateIcons"] = ["/img/ico_coo00.png", "/img/ico_coo01.png", "/img/ico_coo02.png", "/img/ico_coo03.png", "/img/ico_coo04.png"];
+		icon["url"] = "/img/ico_coo0";
 		icon["width"] = 50;
 		icon["height"] = 60;
 		option["icon"] = icon;
@@ -656,7 +670,49 @@
 		var moralMarker = new moralMap.MoralMarker(option);
 		//	    var mark =new BMap.Marker(pointObj,{icon:iconObj});
 		//==================infoWindow-start============================
+
 		var infoWindow = (function() {
+			//���������������
+			var winOpts = {
+				width: 110, // ������������������
+				height: 80, // ������������������
+				title: getTitleOutHtml(), // ������������������
+				offset: new BMap.Size(-8,-5) //���������������������
+			}
+
+			function getTitleOutHtml() {
+				//title���������������...
+				var title = (option["name"] == null) ? "" : option["name"];
+				if(title.length > 13) {
+					title = title.slice(0, 13) + "...";
+				}
+				var titleOutHtml = "";
+				titleOutHtml += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'"
+				titleOutHtml += "title='" + option["name"] + "'>";
+				titleOutHtml += title + "</p>";
+				return titleOutHtml;
+			}
+
+			function getAdressOutHtml() {
+				var address = (option["address"] == null) ? "" : option["address"];
+				if(address.length > 18) {
+					address = address.slice(0, 18) + "...";
+				}
+				var adressOutHtml = "";
+				adressOutHtml += "<div onmouseover='moralMap.clearCloseInfoWindow()'";
+                adressOutHtml +=	"onmouseout='moralMap.closeInfoWindow()'";
+                adressOutHtml	+=" style='font:12px arial,sans-serif;margin-top:12px'><table cellspacing='0' style='overflow:hidden;table-layout:fixed;width:100%;font:12px arial,sans-serif'>";
+				adressOutHtml += "<tbody><tr><td style='vertical-align:top;width:38px;white-space:nowrap;word-break:keep-all'>���������&nbsp;</td><td style='line-height:16px'>";
+				adressOutHtml += address + "&nbsp;";
+				adressOutHtml += "</td></tr>";
+                adressOutHtml += "</tbody></table></div>";
+                //$("#searchParam").val(address);
+				return adressOutHtml;
+			}
+			return new BMap.InfoWindow(getAdressOutHtml(), winOpts);
+		})();
+
+		/*var infoWindow = (function() {
 			//���������������
 			var winOpts = {
 				width: option["online_width"], // ������������������
@@ -679,9 +735,6 @@
 			}
 			return new BMap.InfoWindow("", winOpts);
 		})();
-		if (!showEquipmentInfoWindow) {
-			showEquipmentInfoWindow = infoWindow;
-		}
 		var dataHandle = {
 			_getDataOutHtml: function(data) {
 			    if(data==null||data["state"]==4){
@@ -733,14 +786,14 @@
 				}
 				return grade+"00";
 			}
-		};
+		};*/
 
 		if(moralMarker["infoWindow"] == undefined) {
 			moralMarker["infoWindow"] = infoWindow;
 		}
         var  mouseOverHandle = option['mouseover'];
 		//���������������������
-		moralMarker.addEventListener("mouseover", function() {
+		/*moralMarker.addEventListener("mouseover", function() {
 			if(mouseOverHandle!=null&&mouseOverHandle instanceof  Function){
                 //���arguments���������������
                 var args = Array.prototype.slice.call(arguments);
@@ -766,11 +819,20 @@
 			baiduMap.closeInfoWindow();
 			infoWindow.setContent("");
 			moralMap.openSearchBox();
+		});*/
+		
+		moralMarker.addEventListener("mouseover", function() {
+			moralMap.openInfoWindow(infoWindow, this._point); //������������������
 		});
+		moralMarker.addEventListener("mouseout", function() {
+            moralMap.closeInfoWindow();
+		});
+
 		//==================infoWindow-end============================
 		//���������������
 		moralMap.putEquipment(option['mac'], moralMarker);
 		var _super_refreshState = moralMarker.refreshState;
+		//$("#searchParam").val(option['mac']);
 		return $.extend(moralMarker, {
 			refreshState: function(data) {
 				if(data != null && data!="") {
@@ -778,7 +840,7 @@
 					    this.setData(data); //������������
 						_super_refreshState.call(this, data["state"]);
 						//������������������������������,������������������������
-							   if(infoWindow.isOpen()) {
+							   /*if(infoWindow.isOpen()) {
 									if(data["state"]==4){
 										if(state!=4){
 				                         infoWindow.setHeight(option["offline_height"]);
@@ -807,7 +869,7 @@
 											$(itme_data_mac_key).text(dataValue);
 										}
 									}
-							}
+							}*/
 				}
 			},
 			setData:function(data){
@@ -913,20 +975,53 @@
 	}
 
     moralMap.callJS = function(condition) {
-		var condition = JSON.parse(condition);
-		var new_point = new BMap.Point(condition.longitude, condition.latitude);
-		baiduMap.panTo(new_point);
-		baiduMap.setCenter(new_point);
-		if (condition.type == "mpoint") {
-			baiduMap.setZoom(17);
-			new moralMap.Monitorpoint(condition);
-			moralMap.openInfoWindow(showMonitorpointInfoWindow, new_point);
-			showMonitorpointInfoWindow = null;
-		} else if (condition.type == "device") {
-			baiduMap.setZoom(18);
-			new moralMap.Equipment(condition);
-			moralMap.openInfoWindow(showEquipmentInfoWindow, new_point);
-			showEquipmentInfoWindow = null;
+    	var new_point = new BMap.Point(condition.longitude, condition.latitude);
+    	baiduMap.panTo(new_point);
+    	baiduMap.setCenter(new_point);
+		baiduMap.setZoom(condition.type == "mpoint" ? 17 : 18);
+    	var interval = setInterval(function(){
+    		var marker;
+    		if (condition.type == "mpoint") {
+    			marker = moralMap.getMpoint(condition.id);
+    		} else if (condition.type == "device") {
+    			marker = moralMap.getEquipment(condition.mac);
+    		}
+			if(marker){
+				clearInterval(interval);
+				moralMap.openInfoWindow(marker["infoWindow"], new_point);
+			}
+		}, 50);
+    	
+	}
+
+    var deviceStates ;
+    var monitorPointStates;
+	moralMap.refreshState = function(states) {
+		if (!monitorPointStates) {
+			monitorPointStates = states;
+			deviceStates = [];
+			for (var i in states) {
+				var state = states[i];
+				for (var j in state.devices) {
+					var device = state.devices[j];
+					deviceStates.push(device);
+				}
+			}
+		}
+		for (var i in states) {
+			var state = states[i];
+			var mpoint = moralMap.getMpoint(state.id);
+			if (mpoint) {
+				mpoint.refreshState(state.state);
+			}
+			for (var j in state.devices) {
+				var marker = state.devices[j];
+				var marker_mac = marker["mac"];
+				var equipment = moralMap.getEquipment(marker_mac);
+				if (equipment) {
+					equipment.refreshState(marker);
+				}
+			}
 		}
 	}
 

--
Gitblit v1.8.0