Blame view

node_modules/vue-baidu-map/components/others/Boundary.vue 1.52 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
57
58
59
60
  <template>
    <div v-if="paths.length">
      <bm-polygon
        v-for="(path, index) of paths"
        :key="index"
        :path="path"
        :stroke-color="strokeColor"
        :stroke-weight="strokeWeight"
        :stroke-opacity="strokeOpacity"
        :stroke-style="strokeStyle"
        :fill-opacity="fillOpacity"
        :fill-color="fillColor"
        :mass-clear="massClear"
        :clicking="clicking"
        @click="$emit('click', $event)"
        @dblclick="$emit('dblclick', $event)"
        @mousedown="$emit('mousedown', $event)"
        @mouseup="$emit('mouseup', $event)"
        @mouseout="$emit('mouseout', $event)"
        @mouseover="$emit('mouseover', $event)"
        @remove="$emit('remove', $event)"
      />
    </div>
  </template>
  
  <script>
  import BmPolygon from '../overlays/Polygon.vue'
  import commonMixin from '../base/mixins/common.js'
  // import abstractMixin from '../base/mixins/abstract.js'
  
  export default {
    mixins: [
      commonMixin('abstract')
    ],
    props: ['name', 'strokeColor', 'strokeWeight', 'strokeOpacity', 'strokeStyle', 'fillColor', 'fillOpacity', 'massClear', 'clicking'],
    data () {
      return {
        paths: []
      }
    },
    components: {
      BmPolygon
    },
    watch: {
      name () {
        this.reload()
      }
    },
    methods: {
      load () {
        const {BMap, name} = this
        const bd = new BMap.Boundary()
        bd.get(name, data => {
          this.paths = data.boundaries.map(boundary => (boundary || []).split(';')
             .map(point => (([lng, lat]) => ({lng, lat}))(point.split(',').map(p => +p))))
        })
      }
    }
  }
  </script>