Navigation.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <script>
  2. import commonMixin from '../base/mixins/common.js'
  3. import { createSize } from '../base/factory.js'
  4. import getMapMethod from '../base/methodMap.js';
  5. import { deleteEmptyKey, getConfig } from '../base/util.js'
  6. export default {
  7. name: 'bm-navigation',
  8. render() { },
  9. mixins: [commonMixin('control')],
  10. props: {
  11. anchor: {
  12. type: String
  13. },
  14. offset: {
  15. type: Object
  16. },
  17. type: {
  18. type: String
  19. },
  20. showZoomInfo: {
  21. type: Boolean
  22. },
  23. enableGeolocation: {
  24. type: Boolean,
  25. default: false
  26. }
  27. },
  28. watch: {
  29. anchor() {
  30. this.reload()
  31. },
  32. offset() {
  33. this.reload()
  34. },
  35. type() {
  36. this.reload()
  37. },
  38. showZoomInfo() {
  39. this.reload()
  40. }
  41. },
  42. methods: {
  43. load() {
  44. const { BMap, map, anchor, offset, type, showZoomInfo, enableGeolocation } = this
  45. let navigationOption = {
  46. anchor: window[anchor],
  47. offset: offset && createSize(BMap, offset),
  48. type: window[type],
  49. showZoomInfo,
  50. enableGeolocation
  51. };
  52. deleteEmptyKey(navigationOption);
  53. this.originInstance = new BMap[getMapMethod('NavigationControl')](navigationOption)
  54. map.addControl(this.originInstance)
  55. }
  56. }
  57. }
  58. </script>