wangrong
2025-09-23 40634ebaf5863a599bba8ca2c0575ca079fb8e15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport"
    content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  <meta name="author" content="通感一体" />
  <meta name="apple-touch-fullscreen" content="yes" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <meta name="format-detection" content="telephone=no" />
  <meta name="x5-fullscreen" content="true" />
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
  <!-- 标题及搜索关键字 -->
  <meta name="keywords" content="通感一体" />
  <meta name="description" content="通感一体" />
  <title>通感一体化</title>
</head>
<style>
   #redcap{
      position: absolute;
      top: 50px;
      left: 100px;
      z-index: 10;
    }
</style>
<script
type="text/javascript"
src="./lib/include-lib.js"
libpath="./lib/"
include="jquery,layer,toastr,font-awesome,bootstrap,layer,haoutil,mars3d"
></script>
<script src="./js/offlinemap/map_load.js"></script>
<script src="./js/jizhan_boat.js"></script>
<body>
  <div id="container"></div>
<button id="redcap">Redcap站</button>
<!-- <button id="button1"></button>  
<button id="button2"></button>  -->
<div class="right_box" id="contentBox">
  <div class="change2" onclick="toggleContent()"></div>
  <iframe id="myIframe" src="./index2.html"></iframe>
  <div class="boat_data" id="boat_data">
    <div class="boat_left">
      <iframe src="a.html" frameborder="0" id="video" style="width: 100%;height: 100%;"></iframe>
    </div>
     <div class="boat_right">
      <p style="height: 10%;margin: 0;background-color: rgb(35, 55, 74);color: aliceblue;padding-left: 20px;" onclick="openWindow('cxw.html',600,500)">放大</p>
      <iframe id="chuan" src="./cxw.html" frameborder="0" style="width: 100%;height: 89%;" ></iframe>
    </div> 
    <div class="wurenji_data">
      <p style="height: 10%;margin: 0;background-color: rgb(35, 55, 74);color: aliceblue;padding-left: 20px;" onclick="openWindow('http:\/\/47.100.95.164:38083/planefp-optimize/#/',600,500)">放大</p>
      <iframe src="http://47.100.95.164:38083/planefp-optimize/#/" frameborder="0" style="width: 100%;height: 90%;"></iframe>
    </div>
  </div>
</div>
    
</body>
<!-- <script src="./js/mqtt.js"></script>
<script src="./js/mqttws.js"></script> -->
 
<script>
    var wd_width = 1900
   let width_ = window.screen.width
var isHidden = false
var toggleBtn = document.getElementById('redcap');
var boat_options = {
    size: BMAP_POINT_SIZE_SMALL,
    shape: BMAP_POINT_SHAPE_CIRCLE,
    color: '#ff0000'
}
var wrj_options = {
    size: BMAP_POINT_SIZE_SMALL,
    shape: BMAP_POINT_SHAPE_CIRCLE,
    color: '#fd9319'
}
var boat_points = []
var wrj_points  =[]
    let css_ = document.createElement('link')
    if(width_> wd_width){
      console.log("s")
      css_.href = './css/lage.css'
    }else{
      console.log("l")
      css_.href = './css/small.css'
 
    }
    css_.type = "text/css";
     css_.rel = "stylesheet";
    console.log(css_)
    document.head.appendChild(css_);
 
  let height_ = window.screen.height
  console.log(width_,height_,"宽高")
  var isBoxOpen = false;
    $(document).ready(function () {
 
  
 
        var originalIconSize = new BMap.Size(200, 200);  
// 目标图标尺寸  
var targetIconSize = new BMap.Size(20, 20); 
function addLabel_(maker,text,color,x,y){
  let label = new BMap.Label(text, {offset: new BMap.Size(x, y)});
  // 设置Label的样式  
  label.setStyle({  
      color: color, // 文本颜色  
      fontSize: "12px", // 字体大小  
      border: "1px solid #ccc", // 边框  
      backgroundColor: "#f5f5f5", // 背景颜色  
      padding: "3px", // 内边距  
      borderRadius: "3px", // 边框圆角  
      boxShadow: "0 1px 5px rgba(0,0,0,0.65)", // 阴影效果  
      textAlign: "center", // 文本对齐方式  
      // width: "80px" // 标签宽度  
  }); 
  maker.setLabel(label); 
} 
  
   
// 计算缩放比例  
var scale = targetIconSize.width / originalIconSize.width; 
 
var baidu_map = new BMap.Map('container'); // 创建Map实例
baidu_map.centerAndZoom(new BMap.Point(122.118792,31.1236), 11); // 初始化地图,设置中心点坐标和地图级别
 
function onTilesLoaded() {  
  baidu_map.setCenter(new BMap.Point(122.118792,31.0736));   
    baidu_map.removeEventListener('tilesloaded', onTilesLoaded);  
}  
baidu_map.addEventListener('tilesloaded', onTilesLoaded);
baidu_map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放
var myIcon = new BMap.Icon("./img2/shexiangtou2_left.png", new BMap.Size(50, 50));
// 创建Marker标注,使用小车图标
var pt = new BMap.Point(121.488792,31.070236);
var marker = new BMap.Marker(pt, {
  icon: myIcon
});
var myIcon = new BMap.Icon("./img2/wurenji2.png", new BMap.Size(50, 50));
// 创建Marker标注,使用小车图标
var pt2 = new BMap.Point(121.3565434886248, 30.84122335627239);
var marker2 = new BMap.Marker(pt2, {
  icon: myIcon
});
// 为按钮1添加点击事件监听器  
var myIcon3 = new BMap.Icon("./img2/shexiangtou2_left.png", new BMap.Size(50, 50));
// 创建Marker标注,使用小车图标
var pt3 = new BMap.Point(121.516777,31.227673);
var marker3 = new BMap.Marker(pt3, {
  icon: myIcon3
});
    
 
addLabel_(marker,"航道杜丰通感","blue",-25,-25)
addLabel_(marker2,"无人机基地通感","blue",-30,-25)
addLabel_(marker3,"航道宬苑通感","black",-25,-25)
  baidu_map.addOverlay(marker3)
  baidu_map.addOverlay(marker2)
  baidu_map.addOverlay(marker)
  let label_ = marker.getLabel()
  let label_2 = marker2.getLabel()
let label_3 = marker3.getLabel()
for(let i=0;i<jizhan_boat.length;i++){
  console.log(jizhan_boat[i],"asdieidkeieid")
  boat_points.push(new BMap.Point(jizhan_boat[i]['lng'], jizhan_boat[i]['lat']))
}
for(let i=0;i<wrj_jizhan.length;i++){
  console.log(wrj_jizhan[i],"asdieidkeieid")
 wrj_points.push(new BMap.Point(wrj_jizhan[i]['lng'], wrj_jizhan[i]['lat']))
}
var pointCollection = new BMap.PointCollection(boat_points, boat_options);
var pointCollection2 = new BMap.PointCollection(wrj_points, wrj_options);
function jizhanbtn(){
  isHidden = !isHidden;  
                  
  // 根据状态设置按钮文字  
  if (isHidden) {  
    console.log(pointCollection,boat_points)
    pointCollection = new BMap.PointCollection(boat_points, boat_options);
    pointCollection2 = new BMap.PointCollection(wrj_points, wrj_options);
    baidu_map.addOverlay(pointCollection);
    baidu_map.addOverlay(pointCollection2);
$('#redcap').css('color', 'red');
      // 假设在这里你隐藏了点集合  
  } else {  
    console.log(pointCollection,boat_points)
    baidu_map.removeOverlay(pointCollection);
    baidu_map.removeOverlay(pointCollection2);
$('#redcap').css('color', 'black');
    // 假设在这里你显示了点集合  
  }  
  
}
$('#redcap').on('click', jizhanbtn); 
 
marker2.addEventListener('click', function() { 
  // window.open('https://www.shipxy.com') 
  label_.setStyle({
    color:"blue"
  })
  label_2.setStyle({
    color:"red"
  })
 
  console.log("dianjile")
  let message_data = {"lat":30.825031,"lng":121.35679,"alt":643.2,"heading":337.4,"pitch":-23,"name":'dy'}
  // 隐藏船舶数据  
  document.querySelector('.right_box').style.display = 'block'; 
  document.querySelector('.boat_left').style.display = 'none';  
  document.querySelector('.boat_right').style.display = 'none';  
  // 显示无人机数据  
  if(width_ > wd_width){
    console.log("eeeee")
    document.querySelector('.right_box').style.width = '66.66%';
    document.querySelector('#boat_data').style.width = '49%'; 
    document.querySelector('#myIframe').style.width = '49%'
  }
  
  document.querySelector('.wurenji_data').style.display = 'block'; 
  iframe.contentWindow.postMessage(message_data, '*');
  let test = iframe.contentWindow
  console.log(test.document.querySelector('body'),"window")
//   if (!isBoxOpen) {  
//     toggleContent();  
//   } 
});
// 为按钮2添加点击事件监听器  
marker.addEventListener('click', function(){  
  
  label_.setStyle({
    color:"red"
  })
  label_2.setStyle({
    color:"blue"
  })
    //const iframe_chuan = document.querySelector("#chuan").contentWindow;
  // console.log(iframe_chuan.document.querySelector(".myflag"))
    // iframe.document.querySelector("body").style.backgroundColor = "blue";
  let message_data = {"lat":31.061703,"lng":121.47786,"alt":310.7,"heading":313.7,"pitch":-18.6,"name":'df'}
  document.querySelector('.right_box').style.display = 'block'; 
   // 隐藏无人机数据  
   document.querySelector('.wurenji_data').style.display = 'none';  
   if(width_ >wd_width){
    console.log("eeeee")
    document.querySelector('.right_box').style.width = '75%';
    document.querySelector('#boat_data').style.width = '65%'; 
    document.querySelector('#myIframe').style.width = '33.33%'
  }
  // 显示船舶数据  
  document.querySelector('.boat_left').style.display = 'block';  
  document.querySelector('.boat_right').style.display = 'block';
  iframe.contentWindow.postMessage(message_data, '*');
 let cxw_data = {"cxw_lat":31.063613,"cxw_lng":121.476388}
  test_iframe.contentWindow.postMessage(cxw_data, '*');
//   if (!isBoxOpen) {  
//     toggleContent();  
//   } 
  });
    // 将标注添加到地图
              // 切换按钮
              $(".category_box").click(function () {
                $(".category_box").removeClass("active")
                $(this).addClass("active")
              })
              // 摄像头折叠
              $(".change2").click(function () {
          label_.setStyle({
            color:"blue"
          })
          label_2.setStyle({
            color:"blue"
          })
// label_3.setStyle({
//           color:"blue"
//         })
                // var $titleHead = $(this).closest(".right_box")
                // $titleHead.toggleClass("collapsed")
              })
            })
    // 获取按钮和iframe元素  
var button1 = document.getElementById('button1');  
var button2 = document.getElementById('button2');  
var iframe = document.getElementById('myIframe');  
var test_iframe = document.getElementById('chuan')
function toggleContent() {  
    document.querySelector('.right_box').style.display = 'none'; 
} 
function openWindow(url,w,h){
  let left = window.screen.width-w-20
  let top = window.screen.height-h-20
  var newWindow = window.open(url, 'cxw', `width=${w}px,height=${h}px,left=${left}px,top=${top}px`);
 
// 你可以省略left和top特性,这样浏览器会决定新窗口的位置
// var newWindow = window.open('https://example.com', '_blank', 'width=800,height=600');
}
 
 
 
 
 
 
</script>
</html>