Blame view

node_modules/vue-baidu-map/components/controls/OverviewMap.vue 1.1 KB
290144e9   易尊强   第一次
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
54
55
56
  <script>
  import {createSize} from '../base/factory.js'
  import commonMixin from '../base/mixins/common.js'
  import bindEvents from '../base/bindEvent.js'
  
  export default {
    name: 'bm-overview-map',
    mixins: [commonMixin('control')],
    render () {},
    props: {
      anchor: {
        type: String
      },
      offset: {
        type: Object
      },
      size: {
        type: Object
      },
      isOpen: {
        type: Boolean
      }
    },
    watch: {
      anchor () {
        this.reload()
      },
      offset () {
        this.reload()
      },
      size () {
        this.reload()
      },
      isOpen () {
        this.reload()
      }
    },
    methods: {
      load () {
        const {BMap, map, isOpen, size, offset, anchor} = this
        const mapTypes = []
        this.mapTypes && this.mapTypes.forEach(item => {
          mapTypes.push(global[item])
        })
        this.originInstance = new BMap.OverviewMapControl({
          anchor: global[anchor],
          offset: createSize(BMap, offset),
          size: createSize(BMap, size),
          isOpen
        })
        bindEvents.call(this, this.originInstance)
        map.addControl(this.originInstance)
      }
    }
  }
  </script>