floorBase.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!-- 底图 -->
  2. <template>
  3. <div id='floor_base'>
  4. <div id='fengMap'></div>
  5. <div class='canvas-container' ref='graphy'>
  6. <canvas id='canvas' :width='canvasWidth' :height='canvasHeight' tabindex='0'></canvas>
  7. </div>
  8. </div>
  9. </template>
  10. <script>
  11. import { SFengParser } from '@saga-web/feng-map'
  12. import { SFloorParser } from '@saga-web/big'
  13. import { SGraphyView, SGraphyScene } from '@saga-web/graphy/lib'
  14. export default {
  15. data() {
  16. return {
  17. appName: '万达可视化系统',
  18. key: '23f30a832a862c58637a4aadbf50a566',
  19. mapServerURL: '/wanda',
  20. fmapID: '1001724_29',
  21. fmap: null,
  22. canvasWidth: 700,
  23. canvasHeight: 800,
  24. fParser: null
  25. }
  26. },
  27. methods: {
  28. init() {
  29. this.clearGraphy()
  30. this.scene = new SGraphyScene()
  31. this.fmap = new SFengParser('fengMap', this.mapServerURL, this.key, this.appName, null)
  32. console.log(this.fmap)
  33. this.fmap.parseData('1001724_29', 1, res => {
  34. console.log(res)
  35. this.fParser = new SFloorParser(null)
  36. console.log(this.fParser)
  37. this.fParser.parseData(res)
  38. this.fParser.spaceList.forEach(t => {
  39. t.connect('click', this, this.spaceClick)
  40. this.scene.addItem(t)
  41. })
  42. this.fParser.wallList.forEach(t => this.scene.addItem(t))
  43. this.fParser.virtualWallList.forEach(t => this.scene.addItem(t))
  44. this.fParser.doorList.forEach(t => this.scene.addItem(t))
  45. this.fParser.columnList.forEach(t => this.scene.addItem(t))
  46. this.fParser.casementList.forEach(t => this.scene.addItem(t))
  47. this.view.scene = this.scene
  48. this.view.fitSceneToView()
  49. })
  50. },
  51. clearGraphy() {
  52. if (this.view) {
  53. this.view.scene = null
  54. return
  55. }
  56. this.view = new SGraphyView('canvas')
  57. }
  58. },
  59. mounted() {
  60. this.canvasWidth = this.$refs.graphy.offsetWidth
  61. this.canvasHeight = this.$refs.graphy.offsetHeight
  62. }
  63. }
  64. </script>
  65. <style lang="less" scoped>
  66. #floor_base {
  67. #fengMap {
  68. position: absolute;
  69. width: 100px;
  70. height: 100px;
  71. z-index: -1;
  72. }
  73. .canvas-container {
  74. width: 100%;
  75. height: 100%;
  76. }
  77. }
  78. </style>