<template>
  <div class="main">
    <CusTab :tabs="[
          {name: '正常地图', value: '1'},
          {name: '弹窗的地图', value: '2'},
      ]" v-model:param="tab"/>
    <div class="content">
      <template v-if="tab === '1'">
        <EasyMapComponent
            class="map"
            @easyMapLoad="mapLoad"
        />
      </template>
      <template v-else-if="tab === '2'">
        <h1>弹窗的地图</h1>
        <el-button type="success" @click="showInfo1 = true">查看位置（map实例自定义操作）</el-button>
        <el-button type="success" @click="showInfo2 = true">查看位置（drawViews方法）</el-button>
        <el-button type="success" @click="showInfo3 = true">标绘（drawEdits方法）</el-button>
        <InfoCom1 v-model:show="showInfo1"/>
        <InfoCom2 v-model:show="showInfo2"/>
        <InfoCom3 v-model:show="showInfo3"/>
      </template>
    </div>
  </div>
</template>

<script lang="ts">
import {
  defineComponent,
  computed,
  onMounted,
  ref,
  reactive,
  watch,
  getCurrentInstance,
  ComponentInternalInstance,
  toRefs,
  nextTick
} from 'vue'
import {useStore} from 'vuex'
import {useRouter, useRoute} from 'vue-router'
import InfoCom1 from './info/info1.vue'
import InfoCom2 from './info/info2.vue'
import InfoCom3 from './info/info3.vue'

export default defineComponent({
  name: '',
  components: {
    InfoCom1,
    InfoCom2,
    InfoCom3
  },
  setup(props, {emit}) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
    const state = reactive({
      map: <any>null,
      mapFunc: null,
      tab: '2',
      showInfo1: false,
      showInfo2: false,
      showInfo3: false,
    })
    const mapLoad = (map, func) => {
      state.map = map
      state.mapFunc = func
    }
    return {
      ...toRefs(state),
      mapLoad
    }
  },
})
</script>

<style scoped lang="scss">
.main {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  .cus-tab {
    background-color: #ffffff;
  }
  .content {
    flex: 1;
  }
}
</style>
