Tile.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <script>
  2. import commonMixin from '../base/mixins/common.js'
  3. import {createBounds} from '../base/factory.js'
  4. export default {
  5. name: 'bm-tile',
  6. render (h) {},
  7. mixins: [commonMixin('layer')],
  8. props: {
  9. transparentPng: {
  10. type: Boolean
  11. },
  12. tileUrlTemplate: {
  13. type: String
  14. },
  15. copyright: {
  16. },
  17. zIndex: {
  18. type: Number
  19. }
  20. },
  21. watch: {
  22. transparentPng () {
  23. this.reload()
  24. },
  25. tileUrlTemplate () {
  26. this.reload()
  27. },
  28. copyright () {
  29. this.reload()
  30. },
  31. zIndex () {
  32. this.reload()
  33. }
  34. },
  35. methods: {
  36. load () {
  37. const {BMap, map, transparentPng, tileUrlTemplate, copyright, zIndex} = this
  38. this.originInstance = new BMap.TileLayer({
  39. transparentPng,
  40. tileUrlTemplate,
  41. copyright: copyright && {
  42. id: copyright.id,
  43. content: copyright.content,
  44. bounds: copyright.bounds && createBounds(copyright.bounds)
  45. },
  46. zIndex
  47. })
  48. map.addTileLayer(this.originInstance)
  49. }
  50. }
  51. }
  52. </script>