uniapp微信小程序配置高德地图

文章描述:

request合法域名

 

1、添加request合法域名

微信小程序开发平台 → 开发管理 → 开发设置 → 服务器域名 → request合法域名

添加:https://restapi.amap.com

 

uniapp是有第三方SDK

使用实例:https://ask.dcloud.net.cn/article/35070

//引入地图sdk
import amap  from '@/untils/amap-wx.130.js'

 

 

data() {
        return {
	   amapPlugin: null,  
            key: '',  
            addressName: '',  
            weather: {  
                hasData: false,  
                data: []  
            }  
        }
},
onLoad() {  
        this.amapPlugin = new amap.AMapWX({  
            key: this.key  
        }); 
	this.getRegeo();
}, 
getRegeo() {  
            uni.showLoading({  
                title: '获取信息中'  
            });  
            this.amapPlugin.getRegeo({  
                success: (data) => {  
                    console.log(data)  
                    this.addressName = data[0].name;  
                    uni.hideLoading();  
                }  
            });  
},

 

发布时间:2025/03/12

发表评论