OverviewMap.vue 1.2 KB

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