index.vue 3.2 KB

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