CityList.vue 855 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. mixins: [commonMixin('control')],
  8. props: {
  9. anchor: {
  10. type: String
  11. },
  12. offset: {
  13. type: Object
  14. }
  15. },
  16. watch: {
  17. anchor () {
  18. this.reload()
  19. },
  20. offset () {
  21. this.reload()
  22. }
  23. },
  24. methods: {
  25. load () {
  26. const {BMap, map, anchor, offset} = this
  27. const self = this
  28. this.originInstance = new BMap.CityListControl({
  29. anchor: global[anchor],
  30. offset: offset && createSize(BMap, offset),
  31. onChangeBefore () {
  32. self.$emit('changeBefore')
  33. },
  34. onChangeAfter () {
  35. self.$emit('changeAfter')
  36. }
  37. })
  38. map.addControl(this.originInstance)
  39. }
  40. }
  41. }
  42. </script>