| | |
| | | style: "normal" //设置地图风格为高端黑 |
| | | } |
| | | map.setMapStyle(mapStyle); |
| | | var showZoom = 12; |
| | | var showZoom = !!arguments[2] |
| | | && arguments[2] <=defaultParam.maxZoom |
| | | && arguments[2] >= defaultParam.minZoom?arguments[2]:12; |
| | | var address = arguments[0]; |
| | | var regoinNames = address.split(" "); |
| | | var cityName = regoinNames.length>1?regoinNames[1]:regoinNames[0]; |
| | |
| | | var startZoom = moralMap.startZoom(); |
| | | //刷新key防止延迟加载 |
| | | // var key = moralMap.lazyKeyer(); |
| | | var confine = moralMap.getZooMConfine(); |
| | | var confine = moralMap.getZoomConfine(); |
| | | if(endZoom > startZoom) { |
| | | //放大超过边界 |
| | | if(endZoom >= confine && startZoom <= confine) { |
| | |
| | | if(!!baiduBounds){ |
| | | this.northeastLng = baiduBounds.xl.lng;//东北角经度,大一点 |
| | | this.northeastLat = baiduBounds.xl.lat;//东北角纬度,大一点 |
| | | this.southwestLng = baiduBounds.Ol.lng;//西北角经度坐标,小一点 |
| | | this.southwestLat = baiduBounds.Ol.lat;//西北角纬度坐标,小一点 |
| | | this.southwestLng = baiduBounds.Ol.lng;//西南角经度坐标,小一点 |
| | | this.southwestLat = baiduBounds.Ol.lat;//西南角经度坐标,小一点 |
| | | }else{ |
| | | this.northeastLng = null;//东北角经度,大一点 |
| | | this.northeastLat = null;//东北角纬度,大一点 |
| | | this.southwestLng = null;//西北角经度坐标,小一点 |
| | | this.southwestLat = null;//西北角纬度坐标,小一点 |
| | | this.southwestLng = null;//西南角经度坐标,小一点 |
| | | this.southwestLat = null;//西南角经度坐标,小一点 |
| | | } |
| | | } |
| | | moralMap.getBounds = function() { |
| | |
| | | } |
| | | moralMap.addOverlay = function(overlay) { |
| | | if(overlay.getMap() != baiduMap) { |
| | | setTimeout(function(){ |
| | | // setTimeout(function(){ |
| | | baiduMap.addOverlay.call(baiduMap, overlay); |
| | | },10); |
| | | // },10); |
| | | baiduMap.addOverlay.call(baiduMap, overlay); |
| | | } |
| | | } |
| | | moralMap.addOverlays = function(overlays) { |
| | |
| | | } |
| | | |
| | | } |
| | | moralMap.removeOverlay = function() { |
| | | moralMap.removeOverlay = function(overlay) { |
| | | // baiduMap.removeOverlay(overlay); |
| | | baiduMap.removeOverlay.apply(baiduMap, arguments); |
| | | } |
| | | moralMap.removeOverlays = function(overlays) { |
| | | if(overlays != null && typeof overlays == 'object') { |
| | | for (var i in overlays) { |
| | | moralMap.removeOverlay(overlays[i]); |
| | | } |
| | | } |
| | | } |
| | | moralMap.getOverlays = function() { |
| | | var overLays = baiduMap.getOverlays.apply(baiduMap, arguments) |
| | |
| | | //new BMap.Marker()这种写法IE7会报错,很奇葩 |
| | | moralMap.MoralMarker.prototype = new BMap.Marker(); |
| | | //监控点对象 包装Mark对象 |
| | | var showMonitorpointInfoWindow = null; |
| | | moralMap.Monitorpoint = function(option) { |
| | | var icon = {}; |
| | | icon["stateIcons"] = ["/img/ico00.png", "/img/ico01.png", "/img/ico02.png", "/img/ico03.png", "/img/ico04.png"]; |
| | | icon["width"] = 50; |
| | | icon["height"] = 50; |
| | | option["icon"] = icon; |
| | | var moralMask = new moralMap.MoralMarker(option); |
| | | var moralMarker = new moralMap.MoralMarker(option); |
| | | // var mark =new BMap.Marker(pointObj,{icon:iconObj}); |
| | | //==================infoWindow-start============================ |
| | | var infoWindow = (function() { |
| | |
| | | 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 += "<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); |
| | | })(); |
| | | if(moralMask["infoWindow"] == undefined) { |
| | | moralMask["infoWindow"] = infoWindow; |
| | | if (!showMonitorpointInfoWindow) { |
| | | showMonitorpointInfoWindow = infoWindow; |
| | | } |
| | | if(moralMarker["infoWindow"] == undefined) { |
| | | moralMarker["infoWindow"] = infoWindow; |
| | | } |
| | | //弹窗打开和关闭 |
| | | moralMask.addEventListener("mouseover", function() { |
| | | moralMarker.addEventListener("mouseover", function() { |
| | | moralMap.openInfoWindow(infoWindow, this._point); //开启信息窗口 |
| | | }); |
| | | moralMask.addEventListener("mouseout", function() { |
| | | moralMarker.addEventListener("mouseout", function() { |
| | | moralMap.closeInfoWindow(); |
| | | }); |
| | | //==================infoWindow-end============================ |
| | | //储存监控点 |
| | | moralMap.putMpoint(option['id'], moralMask); |
| | | return moralMask; |
| | | moralMap.putMpoint(option['id'], moralMarker); |
| | | return moralMarker; |
| | | } |
| | | //储存MonitorPoint对象 |
| | | moralMap.putMpoint = function(key, obj) { |
| | |
| | | } |
| | | //设备以mac为key储存 |
| | | //监控点对象 包装MoralMark对象 |
| | | var showEquipmentInfoWindow = null; |
| | | moralMap.Equipment = function(option) { |
| | | var icon = {}; |
| | | icon["stateIcons"] = ["/img/ico_coo00.png", "/img/ico_coo01.png", "/img/ico_coo02.png", "/img/ico_coo03.png", "/img/ico_coo04.png"]; |
| | |
| | | option["offline_height"] = 80; |
| | | option["online_width"] = 355; |
| | | option["online_height"] = 385; |
| | | var moralMask = new moralMap.MoralMarker(option); |
| | | var moralMarker = new moralMap.MoralMarker(option); |
| | | // var mark =new BMap.Marker(pointObj,{icon:iconObj}); |
| | | //==================infoWindow-start============================ |
| | | var infoWindow = (function() { |
| | |
| | | } |
| | | return new BMap.InfoWindow("", winOpts); |
| | | })(); |
| | | if (!showEquipmentInfoWindow) { |
| | | showEquipmentInfoWindow = infoWindow; |
| | | } |
| | | var dataHandle = { |
| | | _getDataOutHtml: function(data) { |
| | | if(data==null||data["state"]==4){ |
| | |
| | | } |
| | | }; |
| | | |
| | | if(moralMask["infoWindow"] == undefined) { |
| | | moralMask["infoWindow"] = infoWindow; |
| | | if(moralMarker["infoWindow"] == undefined) { |
| | | moralMarker["infoWindow"] = infoWindow; |
| | | } |
| | | var mouseOverHandle = option['mouseover']; |
| | | //弹窗打开和关闭 |
| | | moralMask.addEventListener("mouseover", function() { |
| | | moralMarker.addEventListener("mouseover", function() { |
| | | if(mouseOverHandle!=null&&mouseOverHandle instanceof Function){ |
| | | //将arguments转换成数组 |
| | | var args = Array.prototype.slice.call(arguments); |
| | |
| | | infoWindow.redraw(); |
| | | } |
| | | }); |
| | | moralMask.addEventListener("mouseout", function() { |
| | | moralMarker.addEventListener("mouseout", function() { |
| | | baiduMap.closeInfoWindow(); |
| | | infoWindow.setContent(""); |
| | | moralMap.openSearchBox(); |
| | | }); |
| | | //==================infoWindow-end============================ |
| | | //储存监控点 |
| | | moralMap.putEquipment(option['mac'], moralMask); |
| | | var _super_refreshState = moralMask.refreshState; |
| | | return $.extend(moralMask, { |
| | | moralMap.putEquipment(option['mac'], moralMarker); |
| | | var _super_refreshState = moralMarker.refreshState; |
| | | return $.extend(moralMarker, { |
| | | refreshState: function(data) { |
| | | if(data != null && data!="") { |
| | | var state = this.getOption()["state"]; |
| | |
| | | delete moralMap['_equipments']; |
| | | } |
| | | } |
| | | moralMap.getZooMConfine = function() { |
| | | moralMap.getZoomConfine = function() { |
| | | return 18; |
| | | } |
| | | moralMap.getZoom = function() { |
| | | return baiduMap.getZoom(); |
| | | } |
| | | moralMap.getHorizonMarkers = function(isShow) { |
| | | var bounds = moralMap.getBounds(); |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | |
| | | window.moralMap = moralMap; |
| | | })(jQuery, BMap, window); |