<script setup>
import ball from "./ball.vue";
import centerMap from "./centerMap.vue";
import { townMapCoun } from "@/api/index.js";
import { useAppStore } from "@/store/app.js"
import { onMounted, ref } from "vue";

const appStore = useAppStore();

const list = ref([])

const initData = () => {
  townMapCoun({
    areaCode: appStore.address.areaCode,
    streetCode: appStore.address.streetCode,
  }).then((res) => {
    res.data.townList.forEach(item => {
      list.value.push({
        ...item,
        ...{
          value: [item.lng, item.lat]
        }
      })
    });
  })
}

onMounted(() => {
  initData()
})

</script>

<template>
  <div class="box">
    <!-- <div class="ball">
      <ball class="ball1"></ball>
    </div> -->
    <centerMap v-if="list.length > 0" class="c-map" :list="list"></centerMap>
  </div>
</template>

<style scoped lang="scss">
.box {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  .ball {
    height: 100%;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
  }
  .c-map {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}
</style>
