下沙做网站的,公众号怎么制作投票,济南做网站费用,苏州网站优化找哪家Uniapp 是一种跨平台应用开发框架#xff0c;它能够快速地构建出针对不同平台的应用程序。在Uniapp中#xff0c;实现定位功能也变得十分简单#xff0c;只需要简单的配置就能轻松实现。
一、高德地图根据指定位置获取经纬度 参考地址#xff1a;地理/逆地理编码-基础 API…Uniapp 是一种跨平台应用开发框架它能够快速地构建出针对不同平台的应用程序。在Uniapp中实现定位功能也变得十分简单只需要简单的配置就能轻松实现。
一、高德地图根据指定位置获取经纬度 参考地址地理/逆地理编码-基础 API 文档-开发指南-Web服务 API | 高德地图API
// 获取经纬度uni.request({url: https://restapi.amap.com/v3/geocode/geo?parameters, method:GET,data: {key:您的Key,address:您想要的地址},success: (res) {console.log(高德res,res.data.geocodes)let jd res.data.geocodes[0].location.split(,)[0]let wd res.data.geocodes[0].location.split(,)[1]console.log(jd,wd);},})
二、百度地图根据经纬度获取当前位置 参考地址全球逆地理编码 rgc 反geo检索 | 百度地图API SDK
// 获取当前位置的定位位置let that thisuni.getLocation({type: wgs84,success: function (res) {//经纬度获取const latitude res.latitude;const longitude res.longitude;uni.request({url:https://api.map.baidu.com/reverse_geocoding/v3/,data:{ak:您的key,output:json,coordtype:wgs84ll,location: ${latitude},${longitude}},success:function(data){let strdata.data.result.formatted_addressconsole.log(str);}})},//如果错误打印错误信息fail:function(err){console.log(err);}