Scale.vue 674 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <script>
  2. import commonMixin from '../base/mixins/common.js'
  3. import {createSize} from '../base/factory.js'
  4. export default {
  5. name: 'bm-scale',
  6. render () {},
  7. mixins: [commonMixin('control')],
  8. props: {
  9. anchor: {
  10. type: String
  11. },
  12. offset: {
  13. type: Object
  14. }
  15. },
  16. watch: {
  17. anchor () {
  18. this.reload()
  19. },
  20. offset () {
  21. this.reload()
  22. }
  23. },
  24. methods: {
  25. load () {
  26. const {BMap, map, anchor, offset} = this
  27. this.originInstance = new BMap.ScaleControl({
  28. anchor: global[anchor],
  29. offset: offset && createSize(BMap, offset)
  30. })
  31. map.addControl(this.originInstance)
  32. }
  33. }
  34. }
  35. </script>