uniapp的逆地理编码 和地理编码

1.先打开高德地图api找到那个 地理编码
2.封装好我们的请求
3.逆地理编码 和地理编码 都是固定的 记住自己封装的请求 就可以了 这个 是固定的 方式
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
下面这个是固定的 可以复制过去
getlocation就是uniapp提供的 获取经纬度
然后 下面的 就是高德地图提供的 方法 要想使用我们的 请求地址 然后 发过去 就好了 记住 这个 axios就是 我们上面那个 request的 封装的 方式

import {
	axios
} from './request.js'
const key = 'e7c0ac82423c32f586c191246b1fa6ec'

// 定位的api
export const getLocation = () => {
	return new Promise((resolve, reject) => {
		uni.getLocation({
			altitude: true,
			success(res) {
				const {
					longitude,
					latitude
				} = res
				const point = longitude + ',' + latitude
				resolve(point)
			},
			fail(err) {
				reject(err)
			}
		})
	})
}

// 逆地理编码: 经纬度 ---》 地址
export const regeoApi = (location) => axios('http://restapi.amap.com/v3/geocode/regeo', 'GET', {
	location,
	key
})

// 地理编码
export const geoApi = (address) => axios(
	'http://restapi.amap.com/v3/geocode/geo',
	'GET', {
		address,
		key
	}
)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值