CityList.vue 896 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <script>
  2. import commonMixin from '../base/mixins/common.js'
  3. import { createSize } from '../base/factory.js'
  4. export default {
  5. name: 'bm-city-list',
  6. render() { },
  7. emits: ['changeBefore', 'changeAfter'],
  8. mixins: [commonMixin('control')],
  9. props: {
  10. anchor: {
  11. type: String
  12. },
  13. offset: {
  14. type: Object
  15. }
  16. },
  17. watch: {
  18. anchor() {
  19. this.reload()
  20. },
  21. offset() {
  22. this.reload()
  23. }
  24. },
  25. methods: {
  26. load() {
  27. const { BMap, map, anchor, offset } = this
  28. const self = this
  29. this.originInstance = new BMap.CityListControl({
  30. anchor: window[anchor],
  31. offset: offset && createSize(BMap, offset),
  32. onChangeBefore() {
  33. self.$emit('changeBefore')
  34. },
  35. onChangeAfter() {
  36. self.$emit('changeAfter')
  37. }
  38. })
  39. map.addControl(this.originInstance)
  40. }
  41. }
  42. }
  43. </script>