| | |
| | | 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("您选择地址没有解析到结果!"); |
| | |
| | | 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); |
| | | } |
| | |
| | | var url = option['url']; |
| | | url += "&pageNo=" + pageNo; |
| | | url += "&pageSize=" + pageSize; |
| | | console.log(url); |
| | | // console.log(url); |
| | | $.ajax({ |
| | | type: "get", |
| | | cache: false, |
| | |
| | | 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"]; |
| | |
| | | } |
| | | 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>"; |
| | |
| | | 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============================ |
| | | //储存监控点 |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | //设备以mac为key储存 |
| | | //监控点对象 包装MoralMark对象 |
| | | moralMap.Equipment = function (option) { |
| | |
| | | } |
| | | |
| | | moralMap.showSensors = function (jsonData) { |
| | | if(!jsonData.hasOwnProperty('mac')){ |
| | | if (!jsonData.hasOwnProperty('mac')) { |
| | | infoWindow.setContent(""); |
| | | infoWindow.redraw(); |
| | | }else{ |
| | | } 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']); |
| | |
| | | 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>"); |
| | |
| | | } |
| | | |
| | | window.moralMap = moralMap; |
| | | })(jQuery, BMap, window); |
| | | })(jQuery, BMap, window); |