index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div id="map" class="map" style="width: 100%;height: 100%">
  3. </div>
  4. </template>
  5. <script>
  6. export default {
  7. name: 'bd-map',
  8. props: {
  9. loaded: {
  10. type: Function,
  11. default: () => {},
  12. },
  13. },
  14. mounted() {
  15. this.$nextTick(() => {
  16. const options = {
  17. mapType: BDLayers.Lib.Constant.BaseLayerType.Blank,
  18. mapModel: BDLayers.Lib.Constant.BaseLayerModel.Satellite,
  19. center: [108.95965, 34.2189],
  20. defaultZoom: 14,
  21. showCenter: false,
  22. baseControl: true,
  23. pitch: 45,
  24. lights: {
  25. directional: {
  26. direction: [-1, -1, -1],
  27. color: [1, 1, 1],
  28. },
  29. ambient: {
  30. exposure: 1.426,
  31. hsv: [0, 0, 0],
  32. orientation: 302.553,
  33. },
  34. },
  35. };
  36. bdmap.mapWrapper.loadMainMap('map', options);
  37. this.mapView = bdmap.mapWrapper.MainMap('map');
  38. this.mapView.createGLScense({
  39. sceneConfig: {
  40. environment: {
  41. enable: true, // 是否开启环境天空盒绘制
  42. mode: 1, // 天空盒模式: 0: 氛围模式, 1: 实景模式
  43. level: 0, // 实景模式下的模糊级别,0-3
  44. brightness: 0.915, // 天空盒的明亮度,-1 - 1, 默认为0
  45. },
  46. postProcess: {
  47. enable: true, // 是否开启后处理
  48. },
  49. ground: {
  50. enable: true, // 是否开启地面绘制
  51. renderPlugin: { // 地面的绘制插件,取值范围 lit(pbr) 或者 fill(phong)
  52. type: 'lit', // 用pbr材质渲染三维面数据的渲染插件
  53. },
  54. symbol: {
  55. polygonOpacity: 1, // 透明度 0-1
  56. material: { // 如果绘制插件为lit,设置pbr材质
  57. baseColorFactor: [0.48235, 0.48235, 0.48235, 1], // 基础色,四位归一化数组
  58. hsv: [
  59. 0, 0, -
  60. 0.532,
  61. ], // hsv颜色参数,三位分别是hue,saturation,value,即色相,饱和度和明度,每一位的取值范围都是0-1
  62. roughnessFactor: 0.22, // 粗糙度,取值范围 0 - 1,0为最光滑,1为最粗糙
  63. metallicFactor: 0.58, // 金属度,取值范围 0 - 1,0为非金属,1为金属
  64. },
  65. },
  66. },
  67. },
  68. });
  69. // http://200.200.19.253:31838/bdgis/folder/zy9?time=1728373968099
  70. const d3tiles = new BDLayers.Lib.Layer.CB3DtilesLayer('3dtiles', {
  71. offet: {
  72. from: 'GCJ02',
  73. to: 'WGS84',
  74. },
  75. mapView: this.mapView,
  76. maxCacheSize: 10000,
  77. services: [
  78. {
  79. url: 'http://127.0.0.1:8800/bdgis/folder/zy9/tileset.json', //"http://resource.dvgis.cn/data/3dtiles/dayanta/tileset.json",
  80. maximumScreenSpaceError: 16.0,
  81. heightOffset: 0, //-420,
  82. },
  83. ],
  84. });
  85. const satelliteTileLayer = new BDLayers.Lib.Layer.CBTileLayer('blayer_tdt_s', {
  86. url: [
  87. 'http://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=' + BDLayers.Lib
  88. .Constant.WebMapKeys.Tianditu,
  89. 'http://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=' + BDLayers.Lib
  90. .Constant.WebMapKeys.Tianditu,
  91. ],
  92. subdomains: '01234567',
  93. maxZoom: [18, 18],
  94. minZoom: [3, 3],
  95. });
  96. this.mapView.addCustomLayers(satelliteTileLayer, -1, true);
  97. window.map = this.mapView;
  98. this.loaded(this.mapView);
  99. });
  100. },
  101. data() {
  102. return {
  103. mapView: null,
  104. };
  105. },
  106. created() {
  107. },
  108. methods: {},
  109. };
  110. </script>