<template>
  <div class="main">
    <iframe style="width: 100%;height: 100%" src="http://localhost:8686/login"/>
<!--    <EasyMapComponent-->
<!--        class="map"-->
<!--        @easyMapLoad="mapLoad"-->
<!--    />-->
  </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 * as source from "ol/source";
import * as layer from "ol/layer";
import * as format from "ol/format";

export default defineComponent({
  name: '',
  components: {},
  setup() {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
    const state = reactive({
      map: <any>null,
      mapFunc: <any>null,
      elementLayer: <any>null,
    })
    const mapLoad = (map, func) => {
      state.map = map
      state.mapFunc = func
      initWMSElement()
    }
    const initWMSElement = () => {
      const _tileWMS = new source.TileWMS({
        url: `http://192.168.31.19:8082/poiwmts/color/getTile2`,
        params: {
          'FORMAT': 'image/png8',
          'VERSION': '1.1.1',
          "exceptions": 'application/vnd.ogc.se_inimage',
          refresh: new Date().getTime()
        }
      })
      if (!state.elementLayer) {
        state.elementLayer = new layer.Tile({
          source: _tileWMS,
          zIndex: 2,
        })
        state.map.addLayer(state.elementLayer)
      } else {
        state.elementLayer.setSource(_tileWMS)
      }
    }
    return {
      ...toRefs(state),
      mapLoad
    }
  },
})
</script>

<style scoped lang="scss">
.main {
  width: 100%;
  height: 100vh;
}
</style>
