<template>
  <div class="footer_content">
    中心经度：<span>{{ lon }}</span> ，中心纬度：<span>{{
      lat
    }}</span>
    当前地图缩放级别：<span>{{ zoom }}</span>
    <span class="fuzhi">复制</span>
  </div>
</template>

<script>
import Clipboard from "clipboard";
export default {
  props: {
    lon: {
      type: Number,
      default: 0,
    },
    lat: {
      type: Number,
      default: 0,
    },
    zoom: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      clipboard: null,
    };
  },
  mounted() {
    let that = this;
    this.clipboard = new Clipboard(".fuzhi", {
      // 点击copy按钮，直接通过text直接返回复印的内容
      text: function () {
        return that.lon + " " + that.lat;
      },
    });
    this.clipboard.on("success", function (e) {
      that.$message({
        type: "success",
        message: "坐标复制成功！",
      });
    });

    this.clipboard.on("error", function (e) {
      that.$message({
        type: "success",
        message: "坐标复制失败！",
      });
    });
  },
  methods: {},
};
</script>

<style lang="less">
.footer_content {
  position: absolute;
  height: 36px;
  bottom: 0px;
  right: 0px;
  padding: 0 20px;
  background: #ffffff4d;
  color: #003662;
  font-size: 16px;
  font-weight: bold;
  line-height: 36px;
  text-align: center;
  border-radius: 4px;
  .fuzhi {
    display: inline-block;
    margin-left: 20px;
    cursor: pointer;
    color: #32a4dc;
    &:hover {
      text-decoration: underline;
    }
  }
}
</style>