vue 百度地图 气泡图

 

<template>
 <div class='amount'>
  <baidu-map class="map" :center="{lng: 106.464029, lat: 29.547749}" :zoom="12">
     <bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
    <my-overlay
      :position="{lng: 106.464029, lat: 29.547749}"
      text="沙坪坝区"
      text1="热度 6000"
      :active="active"
      @mouseover.native="active = true"
      @mouseleave.native="active = false">
    </my-overlay>
     <my-overlay
      :position="{lng: 106.579012, lat: 29.613082}"
      text="江北区"
      text1="热度 6000"
      :active="active"
      @mouseover.native="active = true"
      @mouseleave.native="active = false">
    </my-overlay>
    <my-overlay
      :position="{lng: 106.754843, lat: 29.748264}"
      text="渝北区"
      text1="热度 6000"
      :active="active"
      @mouseover.native="active = true"
      @mouseleave.native="active = false">
    </my-overlay>
    <my-overlay
      :position="{lng: 106.400559, lat: 29.812409}"
      text="北碚区"
      text1="热度 6000"
      :active="active"
      @mouseover.native="active = true"
      @mouseleave.native="active = false">
    </my-overlay>
    <my-overlay
      :position="{lng: 106.666279, lat: 29.502902}"
      text="南岸区"
      text1="热度 6000"
      :active="active"
      @mouseover.native="active = true"
      @mouseleave.native="active = false">
    </my-overlay>
    <my-overlay
      :position="{lng: 106.517376, lat: 29.507051}"
      text="九龙坡区"
      text1="热度 6000"
      :active="active"
      @mouseover.native="active = true"
      @mouseleave.native="active = false">
    </my-overlay>
    <my-overlay
      :position="{lng: 106.482881, lat: 29.490453}"
      text="大渡口区"
      text1="热度 6000"
      :active="active"
      @mouseover.native="active = true"
      @mouseleave.native="active = false">
    </my-overlay>
    <my-overlay
      :position="{lng: 106.583096, lat: 29.567178}"
      text="渝中区"
      text1="热度 6000"
      :active="active"
      @mouseover.native="active = true"
      @mouseleave.native="active = false">
    </my-overlay>
  </baidu-map>
 </div>
</template>
<script>
import MyOverlay from './../components/MyOverlay.vue'
export default {
  data () {
    return {
      active: false,
      circlePath: {
        center: {
          lng: 106.464029,
          lat: 29.547749
        },
        radius: 5000
      }
    }
  },
  components: {
    MyOverlay
  },
  methods: {
    updateCirclePath (e) {
      this.circlePath.center = e.target.getCenter()
      this.circlePath.radius = e.target.getRadius()
    }
  }
}
</script>

<style lang='less' scoped>
.map {

  width: 100%;
  height: 800px;
}
</style>
<template>
  <bm-overlay
    ref="customOverlay"
    :class="{sample: true, active}"
    pane="labelPane"
    @draw="draw">
    <div class='bmoverlay'>
      <div class='bmovebox' v-html="text+'<br/>'+text1" @click="handleClick">{{text}}</div>
    </div>
  </bm-overlay>
</template>

<script>
export default {
  props: ['text', 'text1', 'position', 'active'],
  watch: {
    position: {
      handler () {
        this.$refs.customOverlay.reload()
      },
      deep: true
    }
  },
  methods: {
    handleClick () {
      global.alert('Well done.')
    },
    draw ({el, BMap, map}) {
      const {lng, lat} = this.position
      const pixel = map.pointToOverlayPixel(new BMap.Point(lng, lat))
      el.style.left = pixel.x - 60 + 'px'
      el.style.top = pixel.y - 20 + 'px'
    }
  }
}
</script>

<style>
.bmoverlay{
  width: 100%;
  height: 100%;
  background: rgba(186,23,18,1);
  border-radius: 50%;
  padding:2px;
  display: flex;
  align-items: left;
  justify-content:space-around;
   flex-direction: column;
}
.bmovebox{
}
.sample {
  width: 120px;
  height: 120px;
  line-height: 20px;
  border:3px solid  rgba(224,32,32,0.4);
  overflow: hidden;
  /* box-shadow: 0 0 5px #000; */
  color: #fff;
  display: flex;
  align-items: left;
  justify-content:space-around;
   flex-direction: column;
  padding-top: 120px;
  display: table-cell;
  vertical-align:middle;
  text-align: center;
  padding: 10px;
  position: absolute;
  top: 10px;
  border-radius: 50%;
}
.sample.active {
  background: rgba(186,23,18,0.75);
  color: #fff;
}
</style>

 

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值