<template>
  <div id="node4">
    <div class="top-title">已合作社区分布图</div>
    <el-amap
      ref="map"
      :center="mapCenter"
      :zoom="7"
      :map-style="setMapStyle"
      vid="amapDemo"
      class="amap-demo"
    >
      <el-amap-marker
        v-for="(item,index) in markers"
        :key="index"
        :position="item.position"
        :icon="item.icon"
        :title="item.title"
        :offset="item.offset"
        :content="item.content"
      />
    </el-amap>
  </div>
</template>

<script>
// import G2 from '@antv/g2'
// import DataSet from '@antv/data-set'
import $ from 'jquery'
// import AMapUI from 'AMapUI'
import light1 from '@/assets/light1.png'
import light2 from '@/assets/light2.png'
import light3 from '@/assets/light3.png'
import light4 from '@/assets/light4.png'
export default {
  data() {
    return {
      light1,
      light2,
      light3,
      light4,
      markers: [{
        position: [118.633516, 32.069878],
        title: '悦见山',
        offset: [-60, -60],
        content: `<div class='point'>
        <img src='${light1}'>
        <span>悦见山</span>
        </div>`
      }, {
        position: [117.161777, 34.154014],
        title: '致享城',
        offset: [-60, -60],
        content: `<div class='point'>
        <img src='${light2}'>
        <span>致享城</span>
        </div>`
      }, {
        position: [118.753086, 31.972501],
        title: '智慧社区',
        offset: [-60, -60],
        content: `<div class='point'>
        <img src='${light3}'>
        <span>智慧社区</span>
        </div>`
      }, {
        position: [120.064082, 30.343891],
        title: '云谷天境',
        offset: [-60, -60],
        content: `<div class='point'>
        <img src='${light4}'>
        <span>云谷天境</span>
        </div>`
      }],
      mapCenter: [118.753086, 31.972501],
      setMapStyle: 'amap://styles/blue'
    }
  },
  mounted() {
    setInterval(() => {
      this.rander()
    }, 1600)
  },
  methods: {
    rander() {
      $('.point img').animate({ opacity: 0 }, 800).animate({ opacity: 1 }, 800)
    }
  }
}
</script>

<style lang="scss">
#node4{
  border-radius: 5px;
}
.top-title{
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  text-align: center;
  margin-top: 30px;
  z-index: 20;
  color: #A6B9C8;
  font-size: 18px;
}
.point{
  position: relative;
  width: 120px;
  height: 120px;
  img{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
  }
  span{
    position: absolute;
    top: 80%;
    left: 50%;
    transform: translate(-50%,-50%);
    font-size: 12px;
    color: white;
  }
}
</style>
