|
15 | 15 | .form-group label { |
16 | 16 | width: 90px; |
17 | 17 | } |
| 18 | + |
| 19 | + .tips { |
| 20 | + z-index: 1000; |
| 21 | + } |
18 | 22 | </style> |
19 | 23 | </head> |
20 | 24 | <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;"> |
|
40 | 44 | liveDataSet,//渲染用实时点数据集 |
41 | 45 | trackDataSet,//渲染用历史轨迹线数据集 |
42 | 46 | planeStyles, |
43 | | - planeLabels, |
| 47 | + planeLabels,//航班信息提示框集合 |
| 48 | + geoFenceLabels,//地理围栏信息提示框集合 |
44 | 49 | geoFenceLayer, |
45 | 50 | dataUrl = "192.168.13.192:9200"; |
46 | 51 |
|
|
57 | 62 | initMap(); |
58 | 63 | liveESService = new SuperMap.ElasticSearchService(dataUrl, { |
59 | 64 | change: renderLive, |
60 | | - outOfGeoFence: outOfGeoFence |
| 65 | + outOfGeoFence: renderOutOfGeoFenceLabel |
61 | 66 | }); |
62 | 67 | trackESService = new SuperMap.ElasticSearchService(dataUrl, { |
63 | 68 | change: renderTrack |
|
275 | 280 | } |
276 | 281 | } |
277 | 282 |
|
278 | | - //超出地理围栏执行的回调操作 |
279 | | - function outOfGeoFence(data) { |
280 | | - var source = data.hits.hits[0]._source; |
281 | | - var latLng = L.latLng(source.y, source.x); |
282 | | - var content = "<div style='color:red'>航班" + source.ident + "超出围栏</div>"; |
283 | | - L.popup().setLatLng(latLng).setContent(content).openOn(map).addTo(map); |
| 283 | + //更新地理围栏提示框 |
| 284 | + function renderOutOfGeoFenceLabel(data) { |
| 285 | + geoFenceLabels = geoFenceLabels || {}; |
| 286 | + var content = data.hits.hits[0]._source; |
| 287 | + var latlng = L.latLng(content.y, content.x); |
| 288 | + var labelContent = "<div style='color:red'>航班" + content.ident + "超出地理围栏</div>"; |
| 289 | + if (!geoFenceLabels[content.ident]) { |
| 290 | + geoFenceLabels[content.ident] = L.popup({ |
| 291 | + closeOnClick: false, |
| 292 | + autoPan: false, |
| 293 | + maxWidth: 180, |
| 294 | + className: "tips", |
| 295 | + offset: L.point(0, -1) |
| 296 | + }).setContent(labelContent).setLatLng(latlng).addTo(map); |
| 297 | + } else { |
| 298 | + geoFenceLabels[content.ident].setLatLng(latlng).setContent(labelContent).openOn(map); |
| 299 | + } |
284 | 300 | } |
285 | 301 |
|
| 302 | + |
286 | 303 | //点击开始之后配置地理围栏 |
287 | 304 | function setGeoFence() { |
288 | 305 | var geoFence = getGeoFence(); |
|
525 | 542 | map.removeLayer(liveRenderer); |
526 | 543 | liveRenderer = null; |
527 | 544 | } |
528 | | - if(liveDataSet){ |
529 | | - liveDataSet=null; |
| 545 | + if (liveDataSet) { |
| 546 | + liveDataSet = null; |
530 | 547 | } |
531 | 548 | if (planeLabels) { |
532 | 549 | for (var item in planeLabels) { |
|
0 commit comments