vue2.0使用百度地图

1、先安装百度地图,安装方法:npm install vue-baidu-map --save (百度地图
2、在main.js中全局注册

import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
  // ak 是在百度地图开发者平台申请的密钥 详见 http://lbsyun.baidu.com/apiconsole/key */
  ak: 'YOUR_APP_KEY'
})

3、在页面应用

<template>
    <div class="dynamic">
		<div>
			<h3>
				<span>地图信息</span>
				<i title="地图" class="el-icon-map-location" @click="amplification"></i>
			</h3>
			<baidu-map class="bm-view" :center="markerPoint" :zoom="16" :dragging="true" :scroll-wheel-zoom="true" @ready="handler">
				<bm-map-type :map-types="['BMAP_NORMAL_MAP', 'BMAP_HYBRID_MAP']" anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-map-type>
				<bm-marker :position="position" :dragging="false" animation="BMAP_ANIMATION_BOUNCE">
					<bm-info-window :show="show" style="font-size:13px"></bm-info-window>
				</bm-marker> 
			</baidu-map>
    </div>
</template>

<script>
export default {
    data(){
        return {
			markerPoint:{lng: 108.951, lat:34.3285},
			show:false,
			isBig:false,
			values:[],
			position:{lng: 108.951, lat:34.3285}
        }
    },
	methods:{
	handler ({BMap, map}) {
		  // console.log(BMap, map)
			  this.center.lng = 108.951;
			  this.center.lat = 34.3285;
			  this.zoom=15;
		},
	}
}
</script>

<style scoped>
.dynamic{
	display: flex;
	position: relative;
}
.map{
	width: 50%;
	height: 330px;
	transition: 0.5s;
}
.mapBig{
	position: absolute;
	width: 100%;
	height:536px;
	z-index: 3;
	transition: 0.5s;
	top: -218px;
}
.information{
	width: 30%;
}
/* 地图 */
.bm-view {
  width: 100%;
  height: 89%;
}
h3 {
    font-size: 14px;
    line-height: 35px;
    padding: 0 10px;
    background: #f8f8f8;
    border: 1px solid #ddd;
	border-left: 0;
}
.map h3,.mapBig h3,.information h3{
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.map h3 i,.mapBig h3 i{
	font-weight: 700;
	font-size: 17px;
	cursor: pointer;
}
.information h3 img{
	display: block;
	width: 25px;
	transform: rotateY(180deg);
}
</style>
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值