9***@qq.com
9***@qq.com
  • 发布:2023-08-03 17:31
  • 更新:2023-08-03 17:32
  • 阅读:225

uniapp使用高德sdk获取地理位置报错失败

分类:uni-app

<script>
import amap from "@/static/js/amap-wx.130.js"
export default {
data() {
return {
href: 'https://uniapp.dcloud.io/component/README?id=uniui',
amapPlugin: null,
key: '04a869649416ced7f9f561b082f57877'
}
},
onLoad() {

        this.amapPlugin = new amap.AMapWX({  
            //高德地图小程序KEY,替换为自己的KEY,参考:http://ask.dcloud.net.cn/article/35070  
            //https://lbs.amap.com/api/wx/gettingstarted  
            key: this.key  
        });  
        console.log(this.amapPlugin)  
        console.log(this.amapPlugin.getRegeo)  
        //定位地址  
        this.amapPlugin.getRegeo({  
            success: (res) => {  
                console.log(adData)  
                this.tian(adData)  
            }  
        });  
    },  
    methods: {  
        getAddress() {  
            uni.showLoading({  
                title: '获取信息中'  
            });  
            debugger  
            // 成功获取位置  
            this.amapPlugin.getRegeo({  
                success: (data) => {  
                    console.log(data, '当前定位')  
                    uni.hideLoading();  
                },  
                // 获取位置失败  
                fail: (err) => {  
                    uni.showToast({  
                        title: "获取位置失败,请重启小程序",  
                        icon: "error"  
                    })  
                }  
            });  
        }  

    }  
}  

</script>

2023-08-03 17:31 负责人:无 分享
已邀请:

要回复问题请先登录注册