700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 微信小程序调用腾讯地图 点击选择并返回选择位置数据!

微信小程序调用腾讯地图 点击选择并返回选择位置数据!

时间:2022-06-07 14:11:47

相关推荐

微信小程序调用腾讯地图 点击选择并返回选择位置数据!

选择前

选择位置

选择后

上代码:WXML

<view class="cu-form-group border-bottom"><view class="title">详细地址</view><input class="address-right" disabled='{{true}}' required="{{true}}" name="address" value="{{address}}"bindtap="AddressInput" /><text class="cuIcon-locationfill text-green"></text></view>

JS

AddressInput(e) {wx.getSetting({success: function (res) {var statu = res.authSetting;if (!statu['scope.userLocation']) {wx.showModal({title: '发布需要授权定位功能',content: '请确认授权,否则地图功能将无法使用',success: function (tip) {if (tip.confirm) {console.log(tip.confirm)wx.openSetting({success: function (data) {if (data.authSetting["scope.userLocation"] === true) {app.ShowToast("授权成功")} else {app.ShowToast("授权失败,请重新点击")}},fail: function (data) {console.log(data)}})} else {app.ShowToast("授权失败,请重新点击")}},})}}});var that = this;wx.chooseLocation({success: function (res) {console.log(res)that.setData({address: res.address,//调用成功直接设置地址resident: res.name,longitude: res.longitude,latitude: res.latitude})}})},

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。