当前位置: 首页> 文旅> 美景 > uniApp获取实时定位

uniApp获取实时定位

时间:2025/7/11 7:31:33来源:https://blog.csdn.net/m0_38007556/article/details/140017498 浏览次数:0次

通过你获取的key放到项目manifest.json里面,对应填写你所需要的key值,还有高德用户名

用户名:

key值的位置:

代码:

html:

<view class="intList pdNone"><view class="label">详细地址</view><uni-easyinput @iconClick="goLocalAddress" placeholder="请点击图标获取详细地址" v-model="form.address" />
</view>

js:

goLocalAddress() {uni.showLoading({title: '获取中...'})let _this = thisuni.getLocation({geocode: true,type: 'gcj02',success: (res) => {uni.hideLoading()this.form.address = res.address.poiName || res.address.streetthis.form.longitude = res.longitudethis.form.latitude = res.latitude},fail: function(e) {uni.hideLoading()uni.getNetworkType({success: (res) => {},fail: () => {uni.showModal({content: '获取失败!',showCancel: false})}})uni.showToast({title: JSON.stringify(e),icon: 'none'});}});
},

效果:点击图标可直接获取当前位置

关键字:uniApp获取实时定位

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: