1+ <!--********************************************************************
2+ * Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
3+ *********************************************************************-->
4+ <!--********************************************************************
5+ * 该示例需要引入
6+ * mapbox-gl-enhance (https://iclient.supermap.io/web/libs/mapbox-gl-js-enhance/1.12.1-10/mapbox-gl-enhance.js)
7+ * Turf (https://github.com/Turfjs/turf/)
8+ * proj4js (https://github.com/proj4js/proj4js)
9+ * video.js (https://github.com/videojs/video.js)
10+ * opencv (https://github.com/opencv/opencv)
11+ *********************************************************************-->
12+ <!DOCTYPE html>
13+ < html >
14+
15+ < head >
16+ < meta http-equiv ="Content-Type " content ="text/html; charset=utf-8 " />
17+ < title data-i18n ="resources.title_uavVideo "> </ title >
18+ < style type ="text/css ">
19+ body {
20+ margin : 0 ;
21+ padding : 0 ;
22+ }
23+
24+ # map {
25+ position : absolute;
26+ top : 0 ;
27+ bottom : 0 ;
28+ width : 100% ;
29+ }
30+ </ style >
31+ </ head >
32+
33+ < body >
34+ < div id ="map "> </ div >
35+ < script type ="text/javascript " include ="bootstrap " src ="../js/include-web.js "> </ script >
36+ < script type ="text/javascript " include ="mapbox-gl-enhance,proj4,turf,videojs,opencv "
37+ src ="../../dist/mapboxgl/include-mapboxgl.js "> </ script >
38+ < script type ="text/javascript ">
39+ var map , videoLayer ;
40+ var attribution =
41+ "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
42+ " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
43+ " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> " ;
44+ var dataUrl = 'https://iserver.supermap.io/iserver/services/data-video/rest/data' ;
45+ var datasourceName = 'VideoData' ;
46+ var datasetName = 'DJI_09304' ;
47+ var map = new mapboxgl . Map ( {
48+ container : 'map' ,
49+ renderWorldCopies : false ,
50+ style : {
51+ version : 8 ,
52+ sources : {
53+ 'raster-tiles' : {
54+ type : 'raster' ,
55+ tileSize : 256 ,
56+ tiles : [
57+ 'https://t4.tianditu.gov.cn/img_w/wmts?service=WMTS&request=GetTile&version=1.0.0&style=default&tilematrixSet=w&format=tiles&width=256&height=256&layer=img&tilematrix={z}&tilerow={y}&tilecol={x}&tk=1d109683f4d84198e37a38c442d68311'
58+ ]
59+ }
60+ } ,
61+ layers : [
62+ {
63+ id : 'simple-tiles' ,
64+ type : 'raster' ,
65+ source : 'raster-tiles' ,
66+ minzoom : 0 ,
67+ maxzoom : 22
68+ }
69+ ]
70+ } ,
71+ center : [ 104.0685393316582 , 30.491810619411483 ] ,
72+ zoom : 17
73+ } ) ;
74+ map . addControl ( new mapboxgl . NavigationControl ( ) , 'top-left' ) ;
75+ map . addControl ( new mapboxgl . supermap . LogoControl ( { link : 'https://iclient.supermap.io' } ) , 'bottom-right' ) ;
76+ function query ( ) {
77+ var sqlParam = new mapboxgl . supermap . GetFeaturesBySQLParameters ( {
78+ queryParameter : {
79+ name : datasetName + '@' + datasourceName ,
80+ attributeFilter : 'SMID > 0'
81+ } ,
82+ datasetNames : [ datasourceName + ':' + datasetName ]
83+ } ) ;
84+
85+ new mapboxgl . supermap . FeatureService ( dataUrl ) . getFeaturesBySQL ( sqlParam ) . then ( function ( serviceResult ) {
86+ const timeData = [ ] ;
87+ serviceResult . result . features . features [ 0 ] . properties . videoParameters . videoParameterList . forEach ( ( param ) => {
88+ let coordinates1 = [ ] ;
89+ param . extent . points . forEach ( ( coord ) => {
90+ const res = proj4 ( 'EPSG:3857' , 'EPSG:4326' , coord ) ;
91+ coordinates1 . push ( res ) ;
92+ } ) ;
93+ let cameraLocation = param . calibrationModel . cameraLocation ;
94+ let calibrationModel = param . calibrationModel ;
95+ timeData . push ( {
96+ time : param . time ,
97+ extent : [ coordinates1 [ 3 ] , coordinates1 [ 2 ] , coordinates1 [ 1 ] , coordinates1 [ 0 ] ] ,
98+ fovX : calibrationModel . fovX ,
99+ fovY : calibrationModel . fovY ,
100+ centerX : calibrationModel . centerX ,
101+ centerY : calibrationModel . centerY ,
102+ pitch : cameraLocation . cameraPitch ,
103+ roll : cameraLocation . cameraRoll ,
104+ yaw : cameraLocation . cameraYaw ,
105+ x : cameraLocation . cameraX ,
106+ y : cameraLocation . cameraY ,
107+ z : cameraLocation . cameraZ
108+ } ) ;
109+ } ) ;
110+ let coordinates = [ ] ;
111+ turf . featureEach ( serviceResult . result . features , function ( currentFeature , featureIndex ) {
112+ currentFeature . geometry . coordinates [ 0 ] [ 0 ] . forEach ( ( coord ) => {
113+ const res = proj4 ( 'EPSG:3857' , 'EPSG:4326' , coord ) ;
114+ coordinates . push ( res ) ;
115+ } ) ;
116+ } ) ;
117+ var url = serviceResult . result . features . features [ 0 ] . properties . address ;
118+ var cameraLocation = serviceResult . result . features . features [ 0 ] . properties . cameraLocation ;
119+ var calibrationModel =
120+ serviceResult . result . features . features [ 0 ] . properties . videoParameters . videoParameterList [ 0 ] . calibrationModel ;
121+ var clipRegionPoints =
122+ serviceResult . result . features . features [ 0 ] . properties . videoParameters . videoParameterList [ 0 ] . clipRegion
123+ . points ;
124+ videoLayer = new mapboxgl . supermap . VideoLayer ( {
125+ url,
126+ videoParameters : timeData ,
127+ clipRegion : [
128+ [ clipRegionPoints [ 0 ] . x , clipRegionPoints [ 0 ] . y ] ,
129+ [ clipRegionPoints [ 1 ] . x , clipRegionPoints [ 1 ] . y ] ,
130+ [ clipRegionPoints [ 2 ] . x , clipRegionPoints [ 2 ] . y ] ,
131+ [ clipRegionPoints [ 3 ] . x , clipRegionPoints [ 3 ] . y ]
132+ ]
133+ } ) ;
134+ map . addLayer ( videoLayer ) ;
135+ } ) ;
136+ }
137+ map . on ( 'load' , function ( ) {
138+ query ( ) ;
139+ } ) ;
140+ </ script >
141+ </ body >
142+
143+ </ html >
0 commit comments