From 820c6a9e6e0e50f7266b8ccaf9c802a1005bda51 Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Tue, 11 Jun 2019 17:42:39 +0800
Subject: [PATCH] sensor
---
src/main/webapp/js/moralmap.js | 147 +++++++++++++++++++++++++++++++++++++++----------
1 files changed, 117 insertions(+), 30 deletions(-)
diff --git a/src/main/webapp/js/moralmap.js b/src/main/webapp/js/moralmap.js
index 74727d4..35bb72c 100644
--- a/src/main/webapp/js/moralmap.js
+++ b/src/main/webapp/js/moralmap.js
@@ -58,7 +58,9 @@
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];
@@ -120,7 +122,7 @@
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) {
@@ -157,13 +159,13 @@
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() {
@@ -208,9 +210,10 @@
}
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) {
@@ -221,8 +224,16 @@
}
}
- 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)
@@ -545,7 +556,7 @@
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() {
@@ -582,26 +593,26 @@
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(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) {
@@ -637,10 +648,52 @@
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() {
+ //���������������
+ 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 += "</tbody></table></div>";
+ //$("#searchParam").val(address);
+ return adressOutHtml;
+ }
+ return new BMap.InfoWindow(getAdressOutHtml(), winOpts);
+ })();
+
+ /*var infoWindow = (function() {
//���������������
var winOpts = {
width: option["online_width"], // ������������������
@@ -714,14 +767,14 @@
}
return grade+"00";
}
- };
+ };*/
- 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);
@@ -743,23 +796,32 @@
infoWindow.redraw();
}
});
- moralMask.addEventListener("mouseout", function() {
+ moralMarker.addEventListener("mouseout", function() {
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'], moralMask);
- var _super_refreshState = moralMask.refreshState;
- return $.extend(moralMask, {
+ moralMap.putEquipment(option['mac'], moralMarker);
+ var _super_refreshState = moralMarker.refreshState;
+ //$("#searchParam").val(option['mac']);
+ return $.extend(moralMarker, {
refreshState: function(data) {
if(data != null && data!="") {
var state = this.getOption()["state"];
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"]);
@@ -788,7 +850,7 @@
$(itme_data_mac_key).text(dataValue);
}
}
- }
+ }*/
}
},
setData:function(data){
@@ -828,8 +890,11 @@
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();
@@ -888,6 +953,28 @@
}
}
- }
+ }
+
+ moralMap.callJS = function(condition) {
+ 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);
+
+ }
+
+
window.moralMap = moralMap;
})(jQuery, BMap, window);
\ No newline at end of file
--
Gitblit v1.8.0