OverviewMap.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <script>
  2. import {createSize} from '../base/factory.js'
  3. import commonMixin from '../base/mixins/common.js'
  4. import bindEvents from '../base/bindEvent.js'
  5. export default {
  6. name: 'bm-overview-map',
  7. mixins: [commonMixin('control')],
  8. render () {},
  9. props: {
  10. anchor: {
  11. type: String
  12. },
  13. offset: {
  14. type: Object
  15. },
  16. size: {
  17. type: Object
  18. },
  19. isOpen: {
  20. type: Boolean
  21. }
  22. },
  23. watch: {
  24. anchor () {
  25. this.reload()
  26. },
  27. offset () {
  28. this.reload()
  29. },
  30. size () {
  31. this.reload()
  32. },
  33. isOpen () {
  34. this.reload()
  35. }
  36. },
  37. methods: {
  38. load () {
  39. const {BMap, map, isOpen, size, offset, anchor} = this
  40. const mapTypes = []
  41. this.mapTypes && this.mapTypes.forEach(item => {
  42. mapTypes.push(global[item])
  43. })
  44. this.originInstance = new BMap.OverviewMapControl({
  45. anchor: global[anchor],
  46. offset: createSize(BMap, offset),
  47. size: createSize(BMap, size),
  48. isOpen
  49. })
  50. bindEvents.call(this, this.originInstance)
  51. map.addControl(this.originInstance)
  52. }
  53. }
  54. }
  55. </script>