1.安装:
npm install vue-amap --save
2.main.js引入:
import VueAMap from 'vue-amap';
Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
key: 'key',//自己申请的key
plugin: ['AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.Geocoder','AMap.Geolocation'],
v: '1.4.4'
});
3.组件中使用:
<template>
<div class="hello">
<el-amap vid="amapDemo" :center="center" :zoom="zoom" :plugin="plugin" :events="events" class="amap-demo">
<el-amap-marker v-for="(marker, index) in markers" :position="marker.position" :events="marker.events" :visible="marker.visible"
:draggable="marker.draggable" :vid="index"></el-amap-marker>
</el-amap>
<p>当前经纬度:{
{center}}</p>
<p>当前地址:{
{formattedAddress}}</p>
</div>
</template>
<script>
export default {
data: function() {
let self = this
retur

本文介绍了在Vue项目中如何通过vue-amap插件进行地图定位和地址逆解码操作,包括安装vue-amap库,配置main.js以及在组件内具体使用的方法。
最低0.47元/天 解锁文章
334

被折叠的 条评论
为什么被折叠?



