赞
踩
微信内置地图无法获取到具体定位信息,只能在app上获取
效果:
小程序获取当前详细定位解决方案:
<template>
<view>
<view @click="getRegeo">获取当前定位...</view>
<view>地址:{{addressName}}</view>
</view>
</template>
<script>
import amap from '../../common/amap-wx.js'; //引入高德微信小程序版sdk
export default {
data() {
return {
amapPlugin: null,
key: '申请的key',
addressName: ''
}
},
onLoad() {
this.amapPlugin = new amap.AMapWX({
key: this.key
})
},
methods: {
getRegeo() {
const _this = this;
uni.showLoading({
title: '获取信息中'
});
_this.amapPlugin.getRegeo({
success: (data) => {
console.log(data, '当前定位')
_this.addressName = data[0].name;
uni.hideLoading();
},
fail: (err) => {
console.log(err)
}
});
}
}
}
</script>
参考文档:https://ask.dcloud.net.cn/article/35070
转发请注明原创噢~~~~
看完记得点个赞哟!!!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。