Skip to content

Commit 4c40c69

Browse files
committed
fix Elasticsearch服务示例提示不正确
1 parent 3be1893 commit 4c40c69

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

examples/leaflet/timeFlow.html

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
.form-group label {
1616
width: 90px;
1717
}
18+
19+
.tips {
20+
z-index: 1000;
21+
}
1822
</style>
1923
</head>
2024
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
@@ -40,7 +44,8 @@
4044
liveDataSet,//渲染用实时点数据集
4145
trackDataSet,//渲染用历史轨迹线数据集
4246
planeStyles,
43-
planeLabels,
47+
planeLabels,//航班信息提示框集合
48+
geoFenceLabels,//地理围栏信息提示框集合
4449
geoFenceLayer,
4550
dataUrl = "192.168.13.192:9200";
4651

@@ -57,7 +62,7 @@
5762
initMap();
5863
liveESService = new SuperMap.ElasticSearchService(dataUrl, {
5964
change: renderLive,
60-
outOfGeoFence: outOfGeoFence
65+
outOfGeoFence: renderOutOfGeoFenceLabel
6166
});
6267
trackESService = new SuperMap.ElasticSearchService(dataUrl, {
6368
change: renderTrack
@@ -275,14 +280,26 @@
275280
}
276281
}
277282

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+
}
284300
}
285301

302+
286303
//点击开始之后配置地理围栏
287304
function setGeoFence() {
288305
var geoFence = getGeoFence();
@@ -525,8 +542,8 @@
525542
map.removeLayer(liveRenderer);
526543
liveRenderer = null;
527544
}
528-
if(liveDataSet){
529-
liveDataSet=null;
545+
if (liveDataSet) {
546+
liveDataSet = null;
530547
}
531548
if (planeLabels) {
532549
for (var item in planeLabels) {

0 commit comments

Comments
 (0)