|
| 1 | +<!--******************************************************************** |
| 2 | +* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved. |
| 3 | +*********************************************************************--> |
| 4 | +<!DOCTYPE html> |
| 5 | +<html> |
| 6 | + <head> |
| 7 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 8 | + <title data-i18n="resources.title_videoLayer"></title> |
| 9 | + <style type="text/css"> |
| 10 | + body { |
| 11 | + margin: 0; |
| 12 | + padding: 0; |
| 13 | + } |
| 14 | + |
| 15 | + #map { |
| 16 | + position: absolute; |
| 17 | + top: 0; |
| 18 | + bottom: 0; |
| 19 | + width: 100%; |
| 20 | + } |
| 21 | + </style> |
| 22 | + </head> |
| 23 | + <body> |
| 24 | + <div id="map"></div> |
| 25 | + <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script> |
| 26 | + <script |
| 27 | + type="text/javascript" |
| 28 | + include="mapbox-gl-enhance,proj4,turf,videojs,opencv" |
| 29 | + src="../../dist/mapboxgl/include-mapboxgl.js" |
| 30 | + ></script> |
| 31 | + <script type="text/javascript"> |
| 32 | + var host = window.isLocal ? window.server : 'https://iserver.supermap.io'; |
| 33 | + var map, |
| 34 | + videoLayer, |
| 35 | + url = host + '/iserver/services/map-world/rest/maps/World'; |
| 36 | + var attribution = |
| 37 | + "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" + |
| 38 | + " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" + |
| 39 | + " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> "; |
| 40 | + var dataUrl = 'http://172.16.14.199:8090/iserver/services/data-demo-3/rest/data'; |
| 41 | + var datasourceName = 'VideoData'; |
| 42 | + var datasetName = 'DJI_0937_2'; |
| 43 | + var count = 0; |
| 44 | + var videoMap; |
| 45 | + |
| 46 | + function query1(dstName, datasource = 'Xinchuan') { |
| 47 | + var sqlParam = new mapboxgl.supermap.GetFeaturesBySQLParameters({ |
| 48 | + queryParameter: { |
| 49 | + name: dstName + '@' + datasource, |
| 50 | + attributeFilter: 'SMID > 0' |
| 51 | + }, |
| 52 | + datasetNames: [datasource + ':' + dstName] |
| 53 | + }); |
| 54 | + |
| 55 | + new mapboxgl.supermap.FeatureService(dataUrl).getFeaturesBySQL(sqlParam).then(function (serviceResult) { |
| 56 | + count++; |
| 57 | + var features = serviceResult.result.features; |
| 58 | + if (features.features[0].geometry.type === 'Point') { |
| 59 | + videoMap.addLayer({ |
| 60 | + id: 'symbol' + count, |
| 61 | + type: 'symbol', |
| 62 | + source: { |
| 63 | + type: 'geojson', |
| 64 | + data: features |
| 65 | + }, |
| 66 | + layout: { |
| 67 | + 'icon-image': 'ro-communal-3', |
| 68 | + 'text-anchor': 'bottom', |
| 69 | + 'text-field': '{NAME}', |
| 70 | + 'icon-text-fit': 'both', |
| 71 | + 'text-size': 12, |
| 72 | + 'icon-text-fit-padding': [5, 10, 5, 10] |
| 73 | + }, |
| 74 | + paint: { |
| 75 | + 'text-color': 'black' |
| 76 | + } |
| 77 | + // layout: { |
| 78 | + // // 'icon-image': 'ro-communal-4', |
| 79 | + // // 'icon-allow-overlap': true, |
| 80 | + // // 'icon-text-fit': 'both', |
| 81 | + // // 'text-offset': [-1, -1], |
| 82 | + // // 'text-anchor': 'bottom', |
| 83 | + // 'text-field': '{NAME}', |
| 84 | + // 'text-size': 16 |
| 85 | + // }, |
| 86 | + // paint: { |
| 87 | + // 'text-color': 'hsl(0, 0%, 0%)', |
| 88 | + // 'text-opacity': 1, |
| 89 | + // 'text-halo-color': 'hsl(0, 0%, 100%)', |
| 90 | + // 'text-halo-width': 1, |
| 91 | + // 'text-halo-blur': 1 |
| 92 | + // } |
| 93 | + }); |
| 94 | + } else if (features.features[0].geometry.type === 'LineString') { |
| 95 | + if (dstName === 'Road_L') { |
| 96 | + features.features.forEach((f) => { |
| 97 | + f.properties['NAME'] = '新川路'; |
| 98 | + }); |
| 99 | + videoMap.addSource('line_roads', { |
| 100 | + type: 'geojson', |
| 101 | + data: features |
| 102 | + }); |
| 103 | + videoMap.addLayer({ |
| 104 | + id: 'line_road', |
| 105 | + type: 'line', |
| 106 | + source: 'line_roads', |
| 107 | + paint: { |
| 108 | + 'line-width': 8, |
| 109 | + 'line-color': 'hsl(26, 87%, 62%)' |
| 110 | + } |
| 111 | + }); |
| 112 | + videoMap.addLayer({ |
| 113 | + id: 'line_road_2', |
| 114 | + type: 'line', |
| 115 | + source: 'line_roads', |
| 116 | + paint: { |
| 117 | + 'line-width': 4, |
| 118 | + 'line-color': 'hsl(0, 0%, 100%)' |
| 119 | + } |
| 120 | + }); |
| 121 | + |
| 122 | + videoMap.addLayer({ |
| 123 | + id: 'label11111111', |
| 124 | + type: 'symbol', |
| 125 | + source: { |
| 126 | + type: 'geojson', |
| 127 | + data: features |
| 128 | + }, |
| 129 | + layout: { |
| 130 | + 'text-line-height': 1.1, |
| 131 | + 'text-size': 14, |
| 132 | + 'text-font': ['DIN Offc Pro Italic', 'Arial Unicode MS Regular'], |
| 133 | + 'symbol-placement': 'line', |
| 134 | + 'text-field': '{NAME}', |
| 135 | + 'text-letter-spacing': 0.1, |
| 136 | + 'text-max-width': 5 |
| 137 | + }, |
| 138 | + paint: { |
| 139 | + 'text-color': 'hsl(0, 0%, 0%)', |
| 140 | + 'text-halo-color': 'hsl(0, 0%, 100%)', |
| 141 | + 'text-halo-width': 1.25, |
| 142 | + 'text-opacity': { |
| 143 | + base: 1, |
| 144 | + stops: [ |
| 145 | + [13.99, 0], |
| 146 | + [14, 1] |
| 147 | + ] |
| 148 | + } |
| 149 | + } |
| 150 | + }); |
| 151 | + } else { |
| 152 | + videoMap.addSource('line_raod2s', { |
| 153 | + type: 'geojson', |
| 154 | + data: features |
| 155 | + }); |
| 156 | + videoMap.addLayer({ |
| 157 | + id: 'line_raod2', |
| 158 | + type: 'line', |
| 159 | + source: 'line_raod2s', |
| 160 | + paint: { |
| 161 | + 'line-color': 'red', |
| 162 | + 'line-width': 5 |
| 163 | + } |
| 164 | + }); |
| 165 | + videoMap.addLayer({ |
| 166 | + id: 'line_raod2_2', |
| 167 | + type: 'line', |
| 168 | + source: 'line_raod2s', |
| 169 | + paint: { |
| 170 | + 'line-color': 'hsl(26, 87%, 62%)', |
| 171 | + 'line-width': 3 |
| 172 | + } |
| 173 | + }); |
| 174 | + } |
| 175 | + } else { |
| 176 | + videoMap.addLayer({ |
| 177 | + id: 'polygon' + count, |
| 178 | + source: { |
| 179 | + type: 'geojson', |
| 180 | + data: features |
| 181 | + }, |
| 182 | + type: 'fill', |
| 183 | + paint: { |
| 184 | + 'fill-color': 'hsl(200, 100%, 80%)' |
| 185 | + } |
| 186 | + }); |
| 187 | + } |
| 188 | + }); |
| 189 | + } |
| 190 | + |
| 191 | + function query() { |
| 192 | + var sqlParam = new mapboxgl.supermap.GetFeaturesBySQLParameters({ |
| 193 | + queryParameter: { |
| 194 | + name: datasetName + '@' + datasourceName, |
| 195 | + attributeFilter: 'SMID > 0' |
| 196 | + }, |
| 197 | + datasetNames: [datasourceName + ':' + datasetName] |
| 198 | + }); |
| 199 | + |
| 200 | + new mapboxgl.supermap.FeatureService(dataUrl).getFeaturesBySQL(sqlParam).then(function (serviceResult) { |
| 201 | + console.log('serviceResult', serviceResult); |
| 202 | + var url = serviceResult.result.features.features[0].properties.address; |
| 203 | + var cameraLocation = serviceResult.result.features.features[0].properties.cameraLocation; |
| 204 | + var calibrationModel = serviceResult.result.features.features[0].properties.videoParameters.videoParameterList[0].calibrationModel; |
| 205 | + videoMap = new mapboxgl.supermap.VideoMap( |
| 206 | + url, |
| 207 | + { |
| 208 | + fovX: calibrationModel.fovX, |
| 209 | + fovY: calibrationModel.fovY, |
| 210 | + centerX: calibrationModel.centerX, |
| 211 | + centerY: calibrationModel.centerY, |
| 212 | + pitch:cameraLocation.cameraPitch, |
| 213 | + roll: cameraLocation.cameraRoll, |
| 214 | + yaw: cameraLocation.cameraYaw, |
| 215 | + x: cameraLocation.cameraX, |
| 216 | + y: cameraLocation.cameraY, |
| 217 | + z: cameraLocation.cameraZ |
| 218 | + }, |
| 219 | + { |
| 220 | + autoplay: false, |
| 221 | + styleOptions: { |
| 222 | + sprite: 'https://iclient.supermap.io/web/styles/street/sprite', |
| 223 | + glyphs: |
| 224 | + 'https://iserver.supermap.io/iserver/services/map-beijing/rest/maps/beijingMap/tileFeature/sdffonts/{fontstack}/{range}.pbf' |
| 225 | + }, |
| 226 | + }); |
| 227 | + |
| 228 | + videoMap.on('load', function () { |
| 229 | + console.log('videoMap', videoMap); |
| 230 | + var datasetList = ['POI', 'Road_L', 'Water', '写字楼', '学校', '步行道']; |
| 231 | + datasetList.forEach((name) => { |
| 232 | + query1(name); |
| 233 | + }); |
| 234 | + }); |
| 235 | + }); |
| 236 | + } |
| 237 | + |
| 238 | + query(); |
| 239 | + </script> |
| 240 | + </body> |
| 241 | +</html> |
0 commit comments