From f85d0342fdb269aa6e21b76e4707bc268c6099bc Mon Sep 17 00:00:00 2001 From: ZhuDongming <773644075@qq.com> Date: Tue, 28 Apr 2020 17:10:23 +0800 Subject: [PATCH] update去除百度地图poi点击事件 --- src/main/webapp/js/moralmap.js | 193 ++++++++++++++++++++++------------------------- 1 files changed, 90 insertions(+), 103 deletions(-) diff --git a/src/main/webapp/js/moralmap.js b/src/main/webapp/js/moralmap.js index f4b025b..6737c74 100644 --- a/src/main/webapp/js/moralmap.js +++ b/src/main/webapp/js/moralmap.js @@ -46,7 +46,8 @@ moralMap.mapInit = function () { var defaultParam = { minZoom: 12, - maxZoom: 20 + maxZoom: 20, + enableMapClick: false }; if (!!arguments[1]) { $.extend(defaultParam, arguments[1]); @@ -70,6 +71,11 @@ var myGeo = new BMap.Geocoder(); myGeo.getPoint(address, function (point) { if (point) { + if ("���������" == cityName) { + var longitude = 113.30640743; + var latitude = 40.08256467; + var point = new BMap.Point(longitude, latitude); + } map.centerAndZoom(point, showZoom); } else { alert("������������������������������������!"); @@ -310,26 +316,25 @@ return; } var equ = { - methodName: 'chart' == select ? 'showChart' : 'showDeviceMonitor', + methodName: 'showVoc' == select ? 'showVoc' : 'showDeviceMonitor', name: row['name'], mac: (row['mac']).toLowerCase(), longitude: row['longitude'], latitude: row['latitude'], monitorPointId: row['monitorPointId'], - version: row['deviceVersion']['version'] + version: row['deviceVersion']['version'], + provinceCode: row['monitorPoint']['provinceCode'] }; !!select ? equ['monitorPointId'] = row["monitorPointId"] : null; var equStr = JSON.stringify(equ); if (window["console"] != undefined) { - console.log(equStr); + // console.log(equStr); } if (!!window['external'] && !!window['external']['callWin']) { window['external'].callWin(equStr); } else { - if (!!select && select === 'chart' && !!window['external'] && !!window['external']['showChartInfo']) { + if (!!select && select === 'showVoc' && !!window['external'] && !!window['external']['showVocInfo']) { window['external'].showChartInfo(equStr); - } else if (!!window['external'] && !!window['external']['showMonitorInfo']) { - window['external'].showMonitorInfo(equStr); } else { alert(equStr); } @@ -426,7 +431,7 @@ var url = option['url']; url += "&pageNo=" + pageNo; url += "&pageSize=" + pageSize; - console.log(url); + // console.log(url); $.ajax({ type: "get", cache: false, @@ -447,6 +452,15 @@ var state = 'state01'; var stateName = ''; var s = e['state'] == undefined ? 0 : e['state']; + if (deviceStates) { + for (var j in deviceStates) { + var deviceState = deviceStates[j]; + if (deviceState.mac == e['mac']) { + s = deviceState.state; + break; + } + } + } var stateObj = _getStateMap(s); state = stateObj["state"]; stateName = stateObj["stateName"]; @@ -466,9 +480,9 @@ } name = name.substring(0, stop1) + "..." + name.substring(stop2, name.length); } - var li = "<li id='listview_item_" + e['mac'] + "'><span class='list-chart-span' onclick=moralMap.onItermClick(\"" + i + "\",'chart')><img src='/img/chart.png'></span>" + var li = "<li id='listview_item_" + e['mac'] + "'><span class='list-chart-span' onclick=moralMap.onItermClick(\"" + i + "\",'showVoc')><img src='/img/list.png' width='20px'></span>" + "<span id='listview_state_" + e['mac'] + "'class='" + state + "'>" + stateName + "</span>" + - "<div style='cursor: pointer;' onclick=moralMap.onItermClick(\"" + i + "\")>" + name + "</div></li>"; + "<div>" + name + "</div></li>"; outHtml += li; } outHtml += "</ul>"; @@ -572,56 +586,35 @@ 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'>��������� </td><td style='line-height:16px'>"; - adressOutHtml += address + " "; - adressOutHtml += "</td></tr>"; - //adressOutHtml += "<tr><td style='width:98%;padding-top:10px;'colspan='2'><a href='javascript:void(0);' style='display:block;position: relative;float: right;' onclick='moralMap.showPointMonitor("+option.id+")'>������������>></a></td></tr>"; - adressOutHtml += "</tbody></table></div>"; - return adressOutHtml; - } - - return new BMap.InfoWindow(getAdressOutHtml(), winOpts); - })(); + var infoWindow; if (moralMarker["infoWindow"] == undefined) { moralMarker["infoWindow"] = infoWindow; } + //��������������������� - moralMarker.addEventListener("mouseover", function () { + moralMarker.addEventListener("click", function () { + var winOpts = { + width: 250, // ������������������ + height: 160, // ������������������ + // title: getTitleOutHtml(), // ������������������ + offset: new BMap.Size(-8, -5) //��������������������� + } + var winfowText = "<div style='width:250px'>"; + var title = (option["name"] == null) ? "" : option["name"]; + if (title.length > 13) { + title = title.slice(0, 13) + "..."; + } + winfowText += "<p style='width:210px;font:bold 14px/16px arial,sans-serif;margin:0;color:#cc5522;white-space:nowrap;overflow:hidden'" + winfowText += "title='" + option["name"] + "'>"; + winfowText += title + "</p>"; + var listText = '<div id="equ_list" class="listview" style="min-height:50px;overflow:auto;max-height:140px;" ></div>'; + winfowText = winfowText + listText + "</div>"; + var infoWindow = new BMap.InfoWindow(winfowText, winOpts); moralMap.openInfoWindow(infoWindow, this._point); //������������������ }); + moralMarker.addEventListener("mouseout", function () { - moralMap.closeInfoWindow(); + // moralMap.closeInfoWindow(); }); //==================infoWindow-end============================ //��������������� @@ -650,27 +643,18 @@ } } - //���������mac���key������ //��������������� ������MoralMark������ moralMap.Equipment = function (option) { - var sensorsMap; + var sensorsDescriptionMap; var sensorsUnitMap; $.ajax({ url: "getSensorsMap?mac=" + option['mac'], type: "get", dataType: "json", success: function (data) { - sensorsMap = data.data; - } - }); - - $.ajax({ - url: "getSensorsUnitMap?mac=" + option['mac'], - type: "get", - dataType: "json", - success: function (data) { - sensorsUnitMap = data.data; + sensorsDescriptionMap = data[0]; + sensorsUnitMap = data[1]; } }); @@ -844,39 +828,43 @@ } moralMap.showSensors = function (jsonData) { - var address = (option["address"] == null) ? "" : option["address"]; - if (address.length > 18) { - address = address.slice(0, 18) + "..."; - } - 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 sensorsMap) { - if (prop == key) { - var sensorsDescription = sensorsMap[key]; + 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]; + 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)) { moralMap.openInfoWindow(infoWindow, this._point); //������������������ @@ -1065,17 +1053,16 @@ 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); - } + 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); } } + listView.refreshState(deviceStates); for (var i in states) { var state = states[i]; var mpoint = moralMap.getMpoint(state.id); @@ -1094,4 +1081,4 @@ } window.moralMap = moralMap; -})(jQuery, BMap, window); \ No newline at end of file +})(jQuery, BMap, window); -- Gitblit v1.8.0