Skip to content

Commit 096a117

Browse files
committed
fix 实时数据服务示例
1 parent 83eb580 commit 096a117

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

examples/leaflet/dataFlowService.html

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<script type="text/javascript">
1111
var host = window.isLocal ? window.server : "http://117.122.248.69:8090";
1212
var wsHost = "ws:\//" + (window.isLocal ? document.location.hostname + ":8800" : "117.122.248.69:8800");
13-
var token = "ObpcGH_Q3L4d6Ow1FLJlbvn-3joeHSL4puxenZr-hBbG3bqnziyGSf705LFwcMWR48cgIBRb5UH1AghE9HVPSQ..";
13+
var token = "15xQ_l77895DvXHYKWPesgip1mX0VFiT0Xa5kaPi0WakyfhWyX9QwS6yv3Jn1-ByBvKbkI4wrdFDlZL5X6Utow..";
1414
var map,
15-
urlMap = host + "/iserver/services/map-china400/rest/maps/China",
16-
urlQuery = host + "/iserver/services/map-china400/rest/maps/China_4326",
17-
urlDataFlow = wsHost + "/iserver/services/dataflow/dataflow";
15+
urlMap = host + "/iserver/services/map-china400/rest/maps/China",
16+
urlQuery = host + "/iserver/services/map-china400/rest/maps/China_4326",
17+
urlDataFlow = wsHost + "/iserver/services/dataflow/dataflow";
1818
map = L.map('map', {
1919
preferCanvas: true,
2020
crs: L.CRS.EPSG3857,
@@ -27,6 +27,7 @@
2727
SuperMap.SecurityManager.registerToken(urlDataFlow, token);
2828
}
2929

30+
var popup = L.popup({offset: L.point(0, 0), autoPan: true});
3031
//创建DataFlowLayer,创建DataFlowLayer订阅DataFlow并将结果加载到地图上
3132
var dataFlowLayer = L.supermap.dataFlowLayer(urlDataFlow, {
3233
style: function (feature) {
@@ -38,10 +39,11 @@
3839
};
3940
},
4041
onEachFeature: function (feature, layer) {
41-
L.popup({offset: L.point(0, 0)})
42-
.setLatLng(L.GeoJSON.coordsToLatLng(feature.geometry.coordinates))
43-
.setContent(feature.properties.time)
44-
.openOn(map);
42+
popup.setLatLng(L.GeoJSON.coordsToLatLng(feature.geometry.coordinates))
43+
.setContent(feature.properties.time);
44+
if (!popup.isOpen()) {
45+
popup.addTo(map);
46+
}
4547
},
4648
//geometry:{coordinates:[[[116.381741960923,39.8765100055449],[116.414681699817,39.8765100055449],[116.414681699817,39.8415115329708],[116.381741960923, 39.8415115329708],[116.381741960923,39.8765100055449]]],type:"Polygon"},
4749
// excludeField:["id"]
@@ -61,14 +63,14 @@
6163
}
6264
});
6365
L.supermap
64-
.queryService(urlQuery)
65-
.queryBySQL(param, function (serviceResult) {
66-
featureResult = serviceResult;
67-
dataFlowService = L.supermap.dataFlowService(urlDataFlow).initBroadcast();
68-
dataFlowService.on('broadcastSocketConnected', function (e) {
69-
timer = window.setInterval("broadcast()", 2000);
70-
})
71-
});
66+
.queryService(urlQuery)
67+
.queryBySQL(param, function (serviceResult) {
68+
featureResult = serviceResult;
69+
dataFlowService = L.supermap.dataFlowService(urlDataFlow).initBroadcast();
70+
dataFlowService.on('broadcastSocketConnected', function (e) {
71+
timer = window.setInterval("broadcast()", 2000);
72+
})
73+
});
7274
}
7375

7476
var count = 200;

0 commit comments

Comments
 (0)