|
10 | 10 | <script type="text/javascript"> |
11 | 11 | var host = window.isLocal ? window.server : "http://117.122.248.69:8090"; |
12 | 12 | 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.."; |
14 | 14 | 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"; |
18 | 18 | map = L.map('map', { |
19 | 19 | preferCanvas: true, |
20 | 20 | crs: L.CRS.EPSG3857, |
|
27 | 27 | SuperMap.SecurityManager.registerToken(urlDataFlow, token); |
28 | 28 | } |
29 | 29 |
|
| 30 | + var popup = L.popup({offset: L.point(0, 0), autoPan: true}); |
30 | 31 | //创建DataFlowLayer,创建DataFlowLayer订阅DataFlow并将结果加载到地图上 |
31 | 32 | var dataFlowLayer = L.supermap.dataFlowLayer(urlDataFlow, { |
32 | 33 | style: function (feature) { |
|
38 | 39 | }; |
39 | 40 | }, |
40 | 41 | 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 | + } |
45 | 47 | }, |
46 | 48 | //geometry:{coordinates:[[[116.381741960923,39.8765100055449],[116.414681699817,39.8765100055449],[116.414681699817,39.8415115329708],[116.381741960923, 39.8415115329708],[116.381741960923,39.8765100055449]]],type:"Polygon"}, |
47 | 49 | // excludeField:["id"] |
|
61 | 63 | } |
62 | 64 | }); |
63 | 65 | 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 | + }); |
72 | 74 | } |
73 | 75 |
|
74 | 76 | var count = 200; |
|
0 commit comments