1.高德开放平台申请key==https://lbs.amap.com/

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

2.代码

	uni.request({
		url: 'https://restapi.amap.com/v3/geocode/geo?address='+region+'&output=JSON&key=此处为高德开放平台申请的key',
		header: {
			'content-type': "application/x-www-form-urlencoded"
		},
		success: (res) => {
			console.log("地理编码==" + JSON.stringify(res))
			var data = res.data;
			if (data.status == 1) {
				var list=res.data.geocodes
				var a=list[0].location
				var b=a.split(',')
				this.str_huoyun_longitude_chu=b[0]
				this.str_huoyun_latitude_chu=b[1]
				this.huoyun_chu=list[0].location
			} 
		},
		fail(err) {
			
		}
	});
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐