index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. mounted() {
  19. this.$nextTick(() => {
  20. const options = {
  21. mapType: BDLayers.Lib.Constant.BaseLayerType.Blank,
  22. mapModel: BDLayers.Lib.Constant.BaseLayerModel.Satellite,
  23. center: [118.8738802982145, 32.010241883966096],
  24. defaultZoom: 15,
  25. showCenter: true,
  26. baseControl: false,
  27. pitch: 45,
  28. lights: {
  29. directional: {
  30. direction: [-1, -1, -1],
  31. color: [1, 1, 1],
  32. },
  33. ambient: {
  34. exposure: 1.426,
  35. hsv: [0, 0, 0],
  36. orientation: 302.553,
  37. },
  38. },
  39. };
  40. bdmap.mapWrapper.loadMainMap(this.mapId, options);
  41. this.mapView = bdmap.mapWrapper.MainMap(this.mapId);
  42. this.mapView.createGLScense({
  43. sceneConfig: {
  44. environment: {
  45. enable: true, // 是否开启环境天空盒绘制
  46. mode: 1, // 天空盒模式: 0: 氛围模式, 1: 实景模式
  47. level: 0, // 实景模式下的模糊级别,0-3
  48. brightness: 0.915, // 天空盒的明亮度,-1 - 1, 默认为0
  49. },
  50. postProcess: {
  51. enable: true, // 是否开启后处理
  52. },
  53. ground: {
  54. enable: true, // 是否开启地面绘制
  55. renderPlugin: { // 地面的绘制插件,取值范围 lit(pbr) 或者 fill(phong)
  56. type: 'lit', // 用pbr材质渲染三维面数据的渲染插件
  57. },
  58. symbol: {
  59. polygonOpacity: 1, // 透明度 0-1
  60. material: { // 如果绘制插件为lit,设置pbr材质
  61. baseColorFactor: [0.48235, 0.48235, 0.48235, 1], // 基础色,四位归一化数组
  62. hsv: [
  63. 0, 0, -
  64. 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. 'http://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=' + BDLayers.Lib
  77. .Constant.WebMapKeys.Tianditu,
  78. 'http://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=' + BDLayers.Lib
  79. .Constant.WebMapKeys.Tianditu,
  80. ],
  81. subdomains: '01234567',
  82. maxZoom: [18, 18],
  83. minZoom: [3, 3],
  84. });
  85. this.mapView.addCustomLayers(satelliteTileLayer, -1, true);
  86. this.mapView.on('click', function (param) {
  87. console.log(new Date().toLocaleTimeString(),
  88. 'click map on', param.coordinate.toFixed(5).toArray().join());
  89. });
  90. this.loaded(this.mapView);
  91. });
  92. },
  93. data() {
  94. return {
  95. mapView: null,
  96. };
  97. },
  98. created() {
  99. },
  100. methods: {},
  101. };
  102. </script>