vue集成百度地图vue-baidu-map

本文详细介绍了如何在Vue项目中集成并配置vue-baidu-map,包括设置npm数据源、全局注册、页面导入和地图组件的基本使用,以实现地图显示和定位功能。

vue集成百度地图vue-baidu-map

1. Vue Baidu Map文档地址

https://dafrok.github.io/vue-baidu-map/#/zh/index

2. 设置npm数据源

npm config set registry=https://registry.npmmirror.com

查看npm数据源

npm config get registry

3. 安装vue-baidu-map

npm install vue-baidu-map --save

4. 配置vue-baidu-map

4.1 main.js全局注册

import BaiduMap from 'vue-baidu-map'

Vue.use(BaiduMap, {
  ak: ''
})

4.2 vue页面设置

index.vue

<template>
<baidu-map class="bm-view" :center="center" :zoom="zoom" :scroll-wheel-zoom="true">
			<bm-scale anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-scale>
			<bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
			<bm-geolocation anchor="BMAP_ANCHOR_BOTTOM_RIGHT" :showAddressBar="true" :autoLocation="true"></bm-geolocation>
		</baidu-map>
</template>
  <script>
  export default {
	name: 'Index',
	components: {
	},
	data() {
	  return {
		lineChartData: lineChartData.newVisitis,
		center: {lng: 108.889191, lat:34.274342},
		zoom: 15
	  }
	},
  }
  </script>
<style>
  .bm-view {
	width: 100%;
	height: 500px;
  }
  </style>

4.3 效果

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值