| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | moralMap.WindMarker = function (option, target) { |
| | | var _option = option; |
| | | var _pointObj = new BMap.Point(_option['longitude'], _option['latitude']); |
| | | var _iconObj = new BMap.Icon("/img/wind_dir.png", new BMap.Size(25, 25)); |
| | | this._point = _pointObj; |
| | | |
| | | this.constructor.call(this, _pointObj, { |
| | | icon: _iconObj, |
| | | offset: new BMap.Size(0, -35), |
| | | enableMassClear: true |
| | | }) |
| | | return $.extend(this, { |
| | | refreshWindDir: function (windDir) { |
| | | //状态发生变化的时候设置图标风向 |
| | | this.setRotation(windDir); |
| | | }, |
| | | getOption: function () { |
| | | return _option; |
| | | }, |
| | | setOption: function (option) { |
| | | _option = option; |
| | | } |
| | | }) |
| | | |
| | | } |
| | | |
| | | //new BMap.Marker()这种写法IE7会报错,很奇葩 |
| | | moralMap.MoralMarker.prototype = new BMap.Marker(); |
| | | moralMap.WindMarker.prototype = new BMap.Marker(); |
| | | //监控点对象 包装Mark对象 |
| | | moralMap.Monitorpoint = function (option) { |
| | | if (monitorPointStates) { |
| | |
| | | } |
| | | }); |
| | | |
| | | moralMap.Device = function (option) { |
| | | if (deviceStates) { |
| | | for (var i in deviceStates) { |
| | | var state = deviceStates[i]; |
| | | if (state.id == option.id) { |
| | | option.state = state.state; |
| | | } |
| | | } |
| | | } |
| | | var windMarker = new moralMap.WindMarker(option); |
| | | moralMap.putDevice(option['mac'], windMarker); |
| | | var refreshWindMarker = windMarker.refreshWindDir; |
| | | return $.extend(windMarker, { |
| | | refreshWindDir: function (data) { |
| | | if (data != null && data != "") { |
| | | this.setData(data); //更新数据 |
| | | refreshWindMarker.call(this, data["e23"]); |
| | | } |
| | | }, |
| | | setData: function (data) { |
| | | var option = this.getOption(); |
| | | option["data"] = data; |
| | | this.setOption(option); |
| | | }, |
| | | getData: function () { |
| | | return this.getOption()["data"]; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //设备以mac为key储存 |
| | | //监控点对象 包装MoralMark对象 |
| | | moralMap.Equipment = function (option) { |
| | |
| | | } |
| | | var mouseOverHandle = option['mouseover']; |
| | | moralMarker.addEventListener("mouseover", function () { |
| | | var obj = {}; |
| | | /* var obj = {}; |
| | | obj['methodName'] = 'deliverMac'; |
| | | obj['mac'] = option['mac']; |
| | | var objStr = JSON.stringify(obj); |
| | |
| | | window['external'].callWin(objStr); |
| | | } else { |
| | | alert(objStr); |
| | | } |
| | | }*/ |
| | | |
| | | moralMap.showSensors = function (jsonData) { |
| | | if (!jsonData.hasOwnProperty('mac')) { |
| | | infoWindow.setContent(""); |
| | | infoWindow.redraw(); |
| | | } else { |
| | | var adressOutHtml = '<div style="min-height:20px;overflow:auto;max-height:400px;font-size: 12px;" onmouseover="moralMap.clearCloseInfoWindow()" onmouseout="moralMap.closeInfoWindow()">'; |
| | | var y, m, d, h, mm, s; |
| | | var date = new Date(jsonData['time']); |
| | | y = 1900 + date.getYear(); |
| | | m = "0" + (date.getMonth() + 1); |
| | | d = "0" + date.getDate(); |
| | | h = "0" + date.getHours(); |
| | | mm = "0" + date.getMinutes(); |
| | | s = "0" + date.getSeconds(); |
| | | date = y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length) + " " + h.substring(h.length - 2, h.length) + ":" + mm.substring(mm.length - 2, mm.length) + ":" + s.substring(s.length - 2, s.length); |
| | | adressOutHtml += '<p style="height: 18px;line-height: 18px">' + "时间: " + date + " </p>"; |
| | | for (var prop in jsonData) { |
| | | if (jsonData.hasOwnProperty(prop) && prop != 'ver' && prop != 'methodName' && prop != 'mac' && prop != 'time') { |
| | | for (var key in sensorsDescriptionMap) { |
| | | if (prop == key) { |
| | | var sensorsDescription = sensorsDescriptionMap[key]; |
| | | } |
| | | } |
| | | for (var key in sensorsUnitMap) { |
| | | if (prop == key) { |
| | | var sensorsUnit = sensorsUnitMap[key]; |
| | | if (sensorsUnit == null) { |
| | | sensorsUnit = ""; |
| | | var deviceSensors = jsonData; |
| | | var mac = deviceSensors["mac"]; |
| | | if (mac == option['mac']) { |
| | | if (!jsonData.hasOwnProperty('mac')) { |
| | | infoWindow.setContent(""); |
| | | infoWindow.redraw(); |
| | | } else { |
| | | var adressOutHtml = '<div style="min-height:20px;overflow:auto;max-height:480px;font-size: 12px;" onmouseover="moralMap.clearCloseInfoWindow()" onmouseout="moralMap.closeInfoWindow()">'; |
| | | var y, m, d, h, mm, s; |
| | | var date = new Date($.now()); |
| | | y = 1900 + date.getYear(); |
| | | m = "0" + (date.getMonth() + 1); |
| | | d = "0" + date.getDate(); |
| | | h = "0" + date.getHours(); |
| | | mm = "0" + date.getMinutes(); |
| | | s = "0" + date.getSeconds(); |
| | | date = y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length) + " " + h.substring(h.length - 2, h.length) + ":" + mm.substring(mm.length - 2, mm.length) + ":" + s.substring(s.length - 2, s.length); |
| | | adressOutHtml += '<p style="height: 18px;line-height: 18px">' + "时间: " + date + " </p>"; |
| | | for (var prop in jsonData) { |
| | | if (jsonData.hasOwnProperty(prop) && prop != 'ver' && prop != 'methodName' && prop != 'mac' && prop != 'time') { |
| | | for (var key in sensorsDescriptionMap) { |
| | | if (prop == key) { |
| | | var sensorsDescription = sensorsDescriptionMap[key]; |
| | | } |
| | | } |
| | | for (var key in sensorsUnitMap) { |
| | | if (prop == key) { |
| | | var sensorsUnit = sensorsUnitMap[key]; |
| | | if (sensorsUnit == null) { |
| | | sensorsUnit = ""; |
| | | } |
| | | } |
| | | } |
| | | adressOutHtml += ('<p style="height: 18px;line-height: 18px">' + sensorsDescription + ":" + jsonData[prop] + sensorsUnit + "</p>"); |
| | | } |
| | | adressOutHtml += ('<p style="height: 18px;line-height: 18px">' + sensorsDescription + ":" + jsonData[prop] + sensorsUnit + "</p>"); |
| | | } |
| | | adressOutHtml += "</div>"; |
| | | infoWindow.setContent(adressOutHtml); |
| | | infoWindow.redraw(); |
| | | } |
| | | adressOutHtml += "</div>"; |
| | | infoWindow.setContent(adressOutHtml); |
| | | infoWindow.redraw(); |
| | | } |
| | | } |
| | | /* if (!$.isEmptyObject(sensorInfo)) { |
| | |
| | | }); |
| | | |
| | | moralMarker.addEventListener("mouseout", function () { |
| | | var obj = {}; |
| | | /* var obj = {}; |
| | | obj['methodName'] = 'stopDeliverMac'; |
| | | var objStr = JSON.stringify(obj); |
| | | if (!!window['external'] && !!window['external']['callWin']) { |
| | | window['external'].callWin(objStr); |
| | | } else { |
| | | alert(objStr); |
| | | } |
| | | }*/ |
| | | moralMap.closeInfoWindow(); |
| | | }); |
| | | |
| | |
| | | moralMap.getEquipments = function (key) { |
| | | return moralMap['_equipments']; |
| | | } |
| | | |
| | | moralMap.putDevice = function (key, obj) { |
| | | if (key != null && key != "") { |
| | | key = String.prototype.toLowerCase.call(key); |
| | | if (moralMap['_devices'] == undefined) { |
| | | moralMap['_devices'] = {}; |
| | | } |
| | | moralMap['_devices'][key] = obj; |
| | | } |
| | | } |
| | | |
| | | moralMap.getDevice = function (key) { |
| | | if (key == null) { |
| | | return null; |
| | | } |
| | | key = String.prototype.toLowerCase.call(key); |
| | | if (typeof moralMap['_devices'] === 'object') { |
| | | return moralMap['_devices'][key]; |
| | | } |
| | | } |
| | | |
| | | moralMap.getDevices = function (key) { |
| | | return moralMap['_devices']; |
| | | } |
| | | |
| | | moralMap.clearEquipments = function () { |
| | | if (moralMap['_equipments'] != undefined) { |
| | | delete moralMap['_equipments']; |
| | |
| | | } |
| | | return markers; |
| | | } |
| | | |
| | | moralMap.getHorizonWindMarkers = function (isShow) { |
| | | var bounds = moralMap.getBounds(); |
| | | var oldWindMarkerList; |
| | | var isShow = (isShow) ? baiduMap : null; |
| | | if (moralMap.layer() == "equipments") { |
| | | oldWindMarkerList = moralMap.getDevices(); |
| | | } |
| | | var markers = []; |
| | | if (oldWindMarkerList != null && typeof oldWindMarkerList == "object") { |
| | | for (var i in oldWindMarkerList) { |
| | | var oldWindMarker = oldWindMarkerList[i]; |
| | | if (oldWindMarker != null && oldWindMarker instanceof BMap.Overlay && oldWindMarker.getMap() == isShow) { |
| | | var option = oldWindMarker.getOption(); |
| | | if (typeof option == 'object') { |
| | | var longitude = option['longitude']; |
| | | var latitude = option['latitude']; |
| | | // 检索当前坐标范围内的组件 |
| | | if (longitude < bounds.northeastLng && longitude > bounds.southwestLng && latitude < bounds.northeastLat && latitude > bounds.southwestLat) { |
| | | markers.push(oldWindMarker); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return markers; |
| | | } |
| | | |
| | | moralMap.showPointMonitor = function (id) { |
| | | var mpointMarker = moralMap.getMpoint(id); |
| | | var mpoint = mpointMarker.getOption(); |
| | |
| | | } |
| | | } |
| | | |
| | | moralMap.refreshWindDir = function (devicesInfo) { |
| | | var deviceInfo = devicesInfo; |
| | | var mac = deviceInfo["mac"]; |
| | | var device = moralMap.getDevice(mac); |
| | | if (device) { |
| | | device.refreshWindDir(deviceInfo); |
| | | } |
| | | } |
| | | |
| | | window.moralMap = moralMap; |
| | | })(jQuery, BMap, window); |