Navigation.vue 1.0 KB

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