当前位置:   article > 正文

38 mars3d 对接地图图层 绘制点线面员

38 mars3d 对接地图图层 绘制点线面员

前言

这里主要是展示一下 mars3d 的一个基础的使用 

主要是设计 接入地图服务器的 卫星地图, 普通的二维地图, 增加地区标记 

基础绘制 点线面园 等等

测试用例

  1. <template>
  2. <div style="width: 1920px; height:1080px;">
  3. <div class="mars3dClass" id="mars3dClass"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import * as mars3d from "mars3d";
  8. const Cesium = mars3d.Cesium;
  9. export default {
  10. name: "mars3dMapUsage",
  11. components: {},
  12. props: {},
  13. data() {
  14. return {
  15. map: null,
  16. tdtImgLayer: null,
  17. labelLayer: null,
  18. overlay: null,
  19. mapOptions:{
  20. scene: {
  21. center: {"lat":31.376588,"lng":104.803391,"alt":539.5,"heading":273.6,"pitch":-40.1}
  22. },
  23. basemaps:[
  24. {
  25. type:'group',
  26. layers:[
  27. {
  28. name:'3dtiles地图',
  29. type:'xyz',
  30. url:'/terrainresource/scmf_0to19/{z}/{x}/{y}.png',
  31. }
  32. ],
  33. show:true
  34. },
  35. ]
  36. },
  37. };
  38. },
  39. computed: {},
  40. watch: {},
  41. created() {
  42. },
  43. mounted() {
  44. this.initMap()
  45. // this.test01AddBoundsLayer()
  46. // this.test02AddDtImageLayer()
  47. // this.test03AddDtTDLayer()
  48. // this.test04AddDtLabelLayer()
  49. this.test11AddTerrainLayer()
  50. // this.test05AddImageLayer()
  51. // this.test06AddCircleLayer([104.065735, 30.759462])
  52. // this.test06AddCircleLayer([104.065735, 30.559462], "red")
  53. // this.test07AddBoxLayer()
  54. // this.test08AddCylinderLayer()
  55. // this.test09AddPolylineVolumeLayer()
  56. },
  57. methods: {
  58. initMap() {
  59. this.map = new mars3d.Map("mars3dClass")
  60. this.map.setCameraView({lng: 104.065735, lat: 30.659462, alt: 44160})
  61. },
  62. test01AddBoundsLayer() {
  63. },
  64. test02AddDtImageLayer() {
  65. const tdtImgLayer = new mars3d.layer.TdtLayer({
  66. url: "/tianditu/servlet/GoogleSatelliteMap?x={x}&y={y}&z={z}",
  67. zIndex: 1,
  68. crs: mars3d.CRS.EPSG4490
  69. });
  70. this.map.addLayer(tdtImgLayer);
  71. },
  72. test03AddDtTDLayer() {
  73. const tdtImgLayer = new mars3d.layer.TdtLayer({
  74. url: "/tianditu/servlet/GoogleTDMap?x={x}&y={y}&z={z}",
  75. zIndex: 1,
  76. crs: mars3d.CRS.EPSG4490
  77. });
  78. this.map.addLayer(tdtImgLayer);
  79. },
  80. test04AddDtLabelLayer() {
  81. const labelLayer = new mars3d.layer.TdtLayer({
  82. url: "/tianditu/servlet/GoogleTransparentMap?x={x}&y={y}&z={z}",
  83. zIndex: 1,
  84. crs: mars3d.CRS.EPSG4490
  85. });
  86. this.map.addLayer(labelLayer);
  87. },
  88. test05AddImageLayer() {
  89. const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
  90. this.map.addLayer(graphicLayer);
  91. const graphic = new mars3d.graphic.BillboardEntity({
  92. name: "贴地图标",
  93. position: [104.065735, 30.659462, 1000],
  94. style: {
  95. image: "/img/theme/desktop/17.jpg",
  96. scale: 1,
  97. horizontalOrigin: mars3d.Cesium.HorizontalOrigin.CENTER,
  98. verticalOrigin: mars3d.Cesium.VerticalOrigin.BOTTOM,
  99. clampToGround: true,
  100. },
  101. attr: {remark: "示例3"},
  102. });
  103. graphicLayer.addGraphic(graphic);
  104. },
  105. test06AddCircleLayer(coord, color) {
  106. const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
  107. this.map.addLayer(graphicLayer);
  108. const graphic = new mars3d.graphic.CircleEntity({
  109. position: [coord[0], coord[1], 1000],
  110. style: {
  111. radius: 1800.0,
  112. color: color,
  113. opacity: 1,
  114. outline: true,
  115. outlineWidth: 3,
  116. outlineColor: color,
  117. clampToGround: true,
  118. },
  119. popup: "直接传参的popup",
  120. attr: { remark: "示例6" },
  121. });
  122. graphicLayer.addGraphic(graphic);
  123. },
  124. test07AddBoxLayer() {
  125. const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
  126. this.map.addLayer(graphicLayer);
  127. const graphic = new mars3d.graphic.BoxEntity({
  128. position: new mars3d.LngLatPoint(104.165735, 30.759462, 1000),
  129. style: {
  130. dimensions: new Cesium.Cartesian3(2000.0, 2000.0, 2000.0),
  131. fill: true,
  132. color: "#00ffff",
  133. opacity: 0.9,
  134. heading: 45,
  135. roll: 45,
  136. pitch: 0,
  137. },
  138. attr: { remark: "示例5" },
  139. });
  140. graphicLayer.addGraphic(graphic);
  141. },
  142. test08AddCylinderLayer() {
  143. const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
  144. this.map.addLayer(graphicLayer);
  145. const graphic = new mars3d.graphic.CylinderEntity({
  146. position: [104.265735, 30.759462, 1000],
  147. style: {
  148. length: 3000.0,
  149. topRadius: 0.0,
  150. bottomRadius: 1300.0,
  151. color: "#00FFFF",
  152. opacity: 0.7,
  153. },
  154. popup: "直接传参的popup",
  155. attr: { remark: "示例7" },
  156. });
  157. graphicLayer.addGraphic(graphic);
  158. },
  159. test09AddPolylineVolumeLayer() {
  160. const graphicLayer = new mars3d.layer.GraphicLayer({zIndex: 20});
  161. this.map.addLayer(graphicLayer);
  162. const graphic = new mars3d.graphic.PolylineVolumeEntity({
  163. positions: [
  164. [103.965735, 30.759462, 1000],
  165. [103.975735, 30.81, 1000],
  166. [103.985735, 30.79, 1000],
  167. ],
  168. style: {
  169. shape: "pipeline",
  170. radius: 80,
  171. color: "#3388ff",
  172. opacity: 0.9,
  173. },
  174. attr: { remark: "示例11" },
  175. });
  176. graphicLayer.addGraphic(graphic);
  177. },
  178. test10SetCenter(coord, color) {
  179. this.map.setCameraView(coord);
  180. },
  181. test11AddTerrainLayer() {
  182. this.map.setCameraView({lng: 104.803391, lat: 31.376588, alt: 539.5,heading:273.6,pitch:-40.1});
  183. const layer = new mars3d.layer.XyzLayer({
  184. url: "/terrainresource/xxx/{z}/{x}/{y}.png",
  185. zIndex: 1,
  186. });
  187. this.map.addLayer(layer);
  188. }
  189. }
  190. };
  191. </script>
  192. <style lang="scss">
  193. .mars3dMapUsageClass {
  194. }
  195. .overdelay1 {
  196. position: absolute;
  197. border: 1px greenyellow solid;
  198. width: 200px;
  199. height: 50px;
  200. }
  201. </style>

绘制卫星地图 + 地图标注

执行效果如下 

二维地图 + 地图标注

执行效果如下 

绘制点线面园 

执行效果如下 

卫星地图 + 地图标注 + 点线面园 

执行效果如下 

地形资源页面

执行效果如下 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/327205
推荐阅读
相关标签
  

闽ICP备14008679号