supermap-2.5d.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div id="cesium-container" style="width: 100%; height: 100%;background: none;">
  3. </div>
  4. </template>
  5. <script>
  6. import {
  7. iconList,
  8. } from '@/api/components/supermap.js'
  9. export default {
  10. name: 'sookaSuperMap',
  11. data() {
  12. return {
  13. viewer:null,
  14. scene:null,
  15. handler:null,
  16. pick:null,
  17. back_position:null,
  18. content:null,
  19. stkTerrainProvider:null,
  20. /*************************原地图属性*********************/
  21. isEditableLayers: false, //绘图控件
  22. /*************************原地图属性*********************/
  23. }
  24. },
  25. watch: {
  26. },
  27. mounted() {
  28. this.viewer = new Cesium.Viewer('cesium-container')
  29. //添加SuperMap iServer发布的影像服务
  30. // var layer = this.viewer.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
  31. // url: 'http://121.36.228.94:8090/iserver/services/3D-sipingchangjing/rest/realspace'
  32. // }));
  33. // //添加SuperMap iServer发布的影像服务
  34. // var layer1 = this.viewer.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
  35. // url: 'http://121.36.228.94:8090/iserver/services/map-spyx4326/rest/maps/dem'
  36. // }));
  37. this.scene = this.viewer.scene;
  38. this.scene.lightSource.ambientLightColor = new Cesium.Color(0.65, 0.65, 0.65, 1);
  39. var urlStr = 'http://121.36.228.94:8090/iserver/services/3D-sipingchangjing/rest/realspace';
  40. this.scene.open(urlStr);
  41. //将三维球定位到指定位置,camera是相机,是当前视野范围相机
  42. //destination是相机的目标位置,参数是经度、纬度、高度
  43. //orientation是相机朝向
  44. // heading-代表镜头左右方向,正值为右,负值为左
  45. // pitch-代表镜头上下方向,正值为上,负值为下.
  46. // roll-代表镜头左右倾斜,正值,向右倾斜,负值向左倾斜
  47. this.viewer.camera.flyTo({
  48. destination: Cesium.Cartesian3.fromDegrees(124.5465087890625, 43.0869197845459, 25000),
  49. orientation: {
  50. heading : Cesium.Math.toRadians(348.4202942851978),
  51. pitch : Cesium.Math.toRadians(-30.74026687972041),
  52. roll : Cesium.Math.toRadians(0)
  53. },
  54. complete:function callback() {
  55. // 定位完成之后的回调函数
  56. }
  57. });
  58. },
  59. props: {},
  60. methods: {
  61. //移除之前添加的点
  62. clearM(){
  63. this.viewer.entities.removeAll();
  64. },
  65. /**
  66. * 地图落点
  67. */
  68. setMarkers(makerList){
  69. let that = this;
  70. that.handler = new Cesium.ScreenSpaceEventHandler(this.scene.canvas);
  71. for (let i in makerList) {
  72. let longitude = makerList[i].lng;
  73. let latitude = makerList[i].lat;
  74. that.viewer.entities.add({
  75. name:"",
  76. position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
  77. billboard: {
  78. image: iconList[makerList[i].icon],
  79. width: 48,
  80. height: 48,
  81. heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
  82. disableDepthTestDistance:Number.POSITIVE_INFINITY
  83. },
  84. description: makerList[i].bindPopupHtml,
  85. click: makerList[i].click,
  86. parameter: makerList[i].parameter,
  87. });
  88. }
  89. that.viewer.scene.globe.depthTestAgainstTerrain=false;
  90. that.createLeftClickDescription();
  91. that.createRightClickDescription();
  92. },
  93. /**
  94. *鼠标左击事件是原来的气泡
  95. */
  96. createLeftClickDescription() {
  97. let that = this;
  98. that.handler.setInputAction(function (movement) {
  99. }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  100. },
  101. /**
  102. *鼠标右击事件是原来的点击
  103. */
  104. createRightClickDescription() {
  105. let that = this;
  106. that.handler.setInputAction(function (movement) {
  107. // 监听鼠标的当前位置坐标,然后根据当前坐标去动态更新气泡窗口div的显示位置;
  108. that.pick = that.viewer.scene.pick(movement.position);
  109. if (that.pick && that.pick) {
  110. let id = Cesium.defaultValue(that.viewer.scene.pick(movement.position).id, that.viewer.scene.pick(movement.position).primitive.id);
  111. let clickName = id._click;
  112. that.$emit(clickName, id._parameter)
  113. }
  114. }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
  115. },
  116. /**
  117. * 落点定位
  118. */
  119. dropLocation(lat, lng) {
  120. this.viewer.camera.flyTo({
  121. destination: Cesium.Cartesian3.fromDegrees(lng, lat, 3000),
  122. });
  123. },
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. @import '@/assets/styles/base.scss';
  129. input[type=checkbox] {
  130. margin: 0px 4px 0 0px;
  131. }
  132. label {
  133. display: inline-block;
  134. }
  135. .param-container {
  136. border: none;
  137. }
  138. .titleBox {
  139. margin-bottom: 0px;
  140. }
  141. .sm-div-graphic {
  142. position: absolute;
  143. color: #fff;
  144. font-size: 14px;
  145. }
  146. #test .divpoint {
  147. background: url(../../public/SuperMap3D/examples/webgl/images/qipao1.png) no-repeat;
  148. background-size: cover;
  149. width: 128px;
  150. height: 216px;
  151. }
  152. #test3 .divpoint {
  153. background: url(../../public/SuperMap3D/examples/webgl/images/qipao1.png) no-repeat;
  154. background-size: cover;
  155. width: 230px;
  156. height: 150px;
  157. }
  158. #test .label-wrap {
  159. display: flex;
  160. justify-content: center;
  161. align-content: center;
  162. height: 50px;
  163. }
  164. #test3 .label-wrap {
  165. padding-left: 100px;
  166. padding-top: 8px;
  167. box-sizing: border-box;
  168. }
  169. #test .pop-title {
  170. color: #fff;
  171. margin-top: 11px;
  172. margin-bottom: 4px;
  173. display: flex;
  174. align-items: center;
  175. font-size: 18px;
  176. }
  177. #test .data-li {
  178. font-size: 14px;
  179. margin-top: 15px;
  180. margin-bottom: 5px;
  181. }
  182. #test3 .data-li {
  183. font-size: 14px;
  184. margin-top: 6px;
  185. }
  186. #test2 .divpoint {
  187. background: url(../../public/SuperMap3D/examples/webgl/images/qipao1.png) no-repeat;
  188. background-size: cover;
  189. width: 116px;
  190. height: 120px;
  191. }
  192. #test2 .label-wrap {
  193. box-sizing: border-box;
  194. padding-top: 10px;
  195. padding-left: 51px;
  196. }
  197. </style>