f40_divGraphic_camera_hls.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  6. <meta name="author" content="火星科技 http://mars3d.cn " />
  7. <meta name="apple-touch-fullscreen" content="yes" />
  8. <meta name="apple-mobile-web-app-capable" content="yes" />
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  10. <meta name="format-detection" content="telephone=no" />
  11. <meta name="x5-fullscreen" content="true" />
  12. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
  13. <!-- 标题及搜索关键字 -->
  14. <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
  15. <meta
  16. name="description"
  17. content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
  18. />
  19. <link rel="shortcut icon" type="image/x-icon" href="" />
  20. <title>浮动监控点 </title>
  21. <!--第三方lib-->
  22. <script
  23. type="text/javascript"
  24. src="../lib/include-lib.js"
  25. libpath="../lib/"
  26. include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars3d"
  27. ></script>
  28. <link href="css/style.css" rel="stylesheet" />
  29. <link href="css/divGraphic.css" rel="stylesheet" />
  30. <style>
  31. .mars3d-camera-content {
  32. /* 防止下面的line一直随img动画 */
  33. height: 30px;
  34. }
  35. .mars3d-camera-img {
  36. width: 30px;
  37. height: 30px;
  38. animation: cameraMove 1s linear infinite alternate;
  39. -webkit-animation: cameraMove 1s linear infinite alternate;
  40. }
  41. @keyframes cameraMove {
  42. from {
  43. margin-top: 20px;
  44. }
  45. to {
  46. margin-top: 0px;
  47. }
  48. }
  49. @-webkit-keyframes cameraMove {
  50. from {
  51. margin-top: 20px;
  52. }
  53. to {
  54. margin-top: 0px;
  55. }
  56. }
  57. .mars3d-camera-line {
  58. height: 120px;
  59. width: 5px;
  60. margin-top: 20px;
  61. border-left: 3px dashed #5b8fee;
  62. margin-left: calc(50% - 1px);
  63. }
  64. .mars3d-camera-point {
  65. border-radius: 50%;
  66. width: 8px;
  67. height: 8px;
  68. margin-left: calc(50% - 3px);
  69. background-color: #5b8fee;
  70. }
  71. </style>
  72. </head>
  73. <body class="dark">
  74. <div id="mars3dContainer" class="mars3d-container"></div>
  75. <script src="../lib/video/hls/hls.js"></script>
  76. <script src="./js/common.js"></script>
  77. <script type="text/javascript">
  78. "use script"; //开发环境建议开启严格模式
  79. var map;
  80. function initMap(options) {
  81. //合并属性参数,可覆盖config.json中的对应配置
  82. var mapOptions = mars3d.Util.merge(options, {
  83. scene: {
  84. center: { lat: 31.649617, lng: 117.081721, alt: 444, heading: 348, pitch: -25 },
  85. },
  86. });
  87. //创建三维地球场景
  88. map = new mars3d.Map("mars3dContainer", mapOptions);
  89. // 加载石化工厂模型
  90. let tiles3dLayer = new mars3d.layer.TilesetLayer({
  91. name: "石化工厂",
  92. url: "//data.mars3d.cn/3dtiles/max-shihua/tileset.json",
  93. position: { lng: 117.077158, lat: 31.659116, alt: 24.6 },
  94. maximumScreenSpaceError: 1,
  95. maximumMemoryUsage: 1024,
  96. popup: "all",
  97. });
  98. map.addLayer(tiles3dLayer);
  99. //创建DIV数据图层
  100. var graphicLayer = new mars3d.layer.DivLayer();
  101. map.addLayer(graphicLayer);
  102. graphicLayer.on(mars3d.EventType.click, function (event) {
  103. console.log("您单击了", event);
  104. });
  105. //在layer上绑定右键菜单
  106. graphicLayer.bindContextMenu(
  107. [
  108. {
  109. text: "查看摄像头",
  110. iconCls: "fa fa-trash-o",
  111. callback: function (e) {
  112. let graphic = e.graphic;
  113. haoutil.msg("右键菜单示例");
  114. },
  115. },
  116. ],
  117. { offsetY: -170 }
  118. );
  119. //添加数据
  120. addGraphic(graphicLayer, [117.080397, 31.656139, 33.3]);
  121. addGraphic(graphicLayer, [117.078006, 31.65649, 49.4]);
  122. addGraphic(graphicLayer, [117.080571, 31.657898, 50.2]);
  123. addGraphic(graphicLayer, [117.078331, 31.660016, 47.2]);
  124. }
  125. function addGraphic(graphicLayer, position) {
  126. var graphicImg = new mars3d.graphic.DivGraphic({
  127. position: position,
  128. style: {
  129. html: ` <div class="mars3d-camera-content">
  130. <img class="mars3d-camera-img" src="img/marker/camera.svg" >
  131. </div>
  132. <div class="mars3d-camera-line" ></div>
  133. <div class="mars3d-camera-point"></div>
  134. `,
  135. offsetX: -16,
  136. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 100000),
  137. },
  138. popup: `<video id="videoHLS" muted="muted" autoplay="autoplay" loop="loop" crossorigin="" controls="">
  139. </video>`,
  140. popupOptions: {
  141. offsetY: -170, //显示Popup的偏移值,是DivGraphic本身的像素高度值
  142. template: `<div class="marsBlackPanel animation-spaceInDown">
  143. <div class="marsBlackPanel-text">{content}</div>
  144. <span class="mars3d-popup-close-button closeButton" >×</span>
  145. </div>`,
  146. horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
  147. verticalOrigin: Cesium.VerticalOrigin.CENTER,
  148. },
  149. });
  150. graphicLayer.addGraphic(graphicImg);
  151. // var hlsUrl = "http://ivi.bupt.edu.cn/hls/cctv13.m3u8";
  152. var hlsUrl = "http://1252093142.vod2.myqcloud.com/4704461fvodcq1252093142/f865d8a05285890787810776469/playlist.f3.m3u8";
  153. graphicImg.on(mars3d.EventType.popupOpen, function (event) {
  154. let videoElement = event.container.querySelector("#videoHLS"); //popup对应的DOM
  155. if (window.Hls.isSupported()) {
  156. var hls = new window.Hls();
  157. hls.loadSource(hlsUrl);
  158. hls.attachMedia(videoElement);
  159. hls.on(window.Hls.Events.MANIFEST_PARSED, function () {
  160. videoElement.play();
  161. });
  162. } else if (videoElement.canPlayType("application/vnd.apple.mpegurl")) {
  163. videoElement.src = hlsUrl;
  164. videoElement.addEventListener("loadedmetadata", function () {
  165. videoElement.play();
  166. });
  167. }
  168. });
  169. }
  170. </script>
  171. </body>
  172. </html>