微信小步伐--实现舆图定位---获取经纬度

[复制链接]
发表于 2026-2-10 17:06:27 | 显示全部楼层 |阅读模式
(1)

(2)

(3)

html:
  1.         <view class="titleTwo" style="border: none;">
  2.                                 <view class="fontSize30 invoiceTile">企业地址</view>
  3.                                 <view class="invoiceRight" bind:tap="tapChooseAddress"  data-maptype="2">
  4.                                         <view class="inputRight fontSize30" style="{{detailedAddress=='请选择企业地址'?'color:#777;':''}} height: auto;" >
  5.                                                 {{detailedAddress || '请选择企业地址'}}
  6.                                         </view>
  7.                                 </view>
  8.                                 <view class="clearBoth"></view>
  9.                         </view>
复制代码
js:
  1.         tapChooseAddress(e) {
  2.                 let that = this;
  3.                 let maptype = e.currentTarget.dataset.maptype;
  4.                 // 地图选点
  5.                 wx.chooseLocation({
  6.                   success: function (res) {
  7.                     if(maptype == "1"){
  8.                       that.setData({
  9.                         detailedAddress: res.name,
  10.                         xxdzLongitude: res.longitude,
  11.                         xxdzLatitude: res.latitude,
  12.                       });
  13.                     }else{
  14.                       that.setData({
  15.                         detailedAddress: res.name,
  16.                         xxdzLongitude: res.longitude,//经度
  17.                         xxdzLatitude: res.latitude,//纬度
  18.                       });
  19.                      
  20.                     }
  21.                     
  22.                   },
  23.                   fail: function (err) {
  24.                     console.log(err)
  25.                     wx.showToast({
  26.                       title: '地图位置获取错误',
  27.                       icon: "none"
  28.                     })
  29.                   }
  30.                 })
  31.         },
  32.         // res.longitude,//经度
  33.   //latitude,//纬度
复制代码
app.json:
  1.    "requiredPrivateInfos": [
  2.       "getLocation",
  3.       "chooseLocation"
  4.     ],
  5.     "permission": {
  6.       "scope.userLocation": {
  7.         "desc": "获取用户位置信息用于填写收货地址"
  8.                 }
  9.       },
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!qidao123.com:ToB企服之家,中国第一个企服评测及软件市场,开放入驻,技术点评得现金

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表