<template>
  <div id="floor_base">
    <canvas id="map" :width="initWidth" height="800"></canvas>
  </div>
</template>
<script>
import { ZoneScene } from "@saga-web/cad-engine/lib";
import { FloorView } from "@saga-web/cad-engine/lib/FloorView";
// import { SPainter, SPoint, SLinearGradient } from "@saga-web/draw/lib";
export default {
  data() {
    return {
      view: null, //视图
      ZoneScene: null, //场景类
      initWidth: null, //初始化得宽度
      mapUrl: "/api/download/daas//b2b5a2130cf511eabf9667e7f714e00e.jsonz"
    };
  },
  methods: {
    //     clearImg() {
    //   if (!this.ZoneScene) {
    //     this.ZoneScene = new ZoneScene();
    //   }
    //   // this.ZoneScene.clearMap();
    // },
  },
  mounted() {
    //  将场景赋给view对图进行绘制
    this.initWidth = document.documentElement.clientWidth;
    this.view = new FloorView(`map`);
    this.ZoneScene = new ZoneScene();
    this.ZoneScene.loadUrl(this.mapUrl).then(res => {
      this.view.scene = this.ZoneScene;
      this.view.fitSceneToView();
    });
  }
};
</script>