zhangxiaoxu123
2023-07-05 946ef6d9a54768f34db60b43de5c35f683b4799c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<script>
import commonMixin from '../base/mixins/common.js'
import {createBounds} from '../base/factory.js'
 
export default {
  name: 'bm-tile',
  render (h) {},
  mixins: [commonMixin('layer')],
  props: {
    transparentPng: {
      type: Boolean
    },
    tileUrlTemplate: {
      type: String
    },
    copyright: {
    },
    zIndex: {
      type: Number
    }
  },
  watch: {
    transparentPng () {
      this.reload()
    },
    tileUrlTemplate () {
      this.reload()
    },
    copyright () {
      this.reload()
    },
    zIndex () {
      this.reload()
    }
  },
  methods: {
    load () {
      const {BMap, map, transparentPng, tileUrlTemplate, copyright, zIndex} = this
      this.originInstance = new BMap.TileLayer({
        transparentPng,
        tileUrlTemplate,
        copyright: copyright && {
          id: copyright.id,
          content: copyright.content,
          bounds: copyright.bounds && createBounds(copyright.bounds)
        },
        zIndex
      })
      map.addTileLayer(this.originInstance)
    }
  }
}
</script>