index.vue 3.3 KB

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