微信小程序--实现地图定位---获取经纬度

(1)

(2)

(3)

html:

html 复制代码
	<view class="titleTwo" style="border: none;">
				<view class="fontSize30 invoiceTile">企业地址</view>
				<view class="invoiceRight" bind:tap="tapChooseAddress"  data-maptype="2">
					<view class="inputRight fontSize30" style="{{detailedAddress=='请选择企业地址'?'color:#777;':''}} height: auto;" >
						{{detailedAddress || '请选择企业地址'}}
					</view>
				</view>
				<view class="clearBoth"></view>
			</view>

js:

javascript 复制代码
	tapChooseAddress(e) {
		let that = this;
		let maptype = e.currentTarget.dataset.maptype;
		// 地图选点
		wx.chooseLocation({
		  success: function (res) {
		    if(maptype == "1"){
		      that.setData({
		        detailedAddress: res.name,
		        xxdzLongitude: res.longitude,
		        xxdzLatitude: res.latitude,
		      });
		    }else{
		      that.setData({
		        detailedAddress: res.name,
		        xxdzLongitude: res.longitude,//经度
		        xxdzLatitude: res.latitude,//纬度
		      });
		      
		    }
		    
		  },
		  fail: function (err) {
		    console.log(err)
		    wx.showToast({
		      title: '地图位置获取错误',
		      icon: "none"
		    })
		  }
		})
	},
	// res.longitude,//经度
  //latitude,//纬度

app.json:

javascript 复制代码
   "requiredPrivateInfos": [
      "getLocation",
      "chooseLocation"
    ],
    "permission": {
      "scope.userLocation": {
        "desc": "获取用户位置信息用于填写收货地址"
		}
      },
相关推荐
vipbic3 小时前
独立开发复盘:我用 Uni-app + Strapi v5 肝了一个“会上瘾”的打卡小程序
前端·微信小程序
CDwenhuohuo12 小时前
小程序全局使用api
javascript·vue.js·小程序
智慧景区与市集主理人15 小时前
市集分账混乱?巨有科技智慧小程序实现统一收款、自动分账
大数据·科技·小程序
front-end-zzq15 小时前
瘦了么打卡微信小程序
小程序
2501_9159090615 小时前
苹果App Store上架全流程指南从注册到上线
android·ios·小程序·https·uni-app·iphone·webview
全栈小515 小时前
【小程序】微信小程序在体验版发起支付的时候提示“由于小程序违规,支付功能暂时无法使用”,是不是一脸懵逼
微信小程序·小程序
jingqingdai31 天前
微信小程序 Canvas 2D 踩坑指南:如何优雅地导出高清长图?(附 AI 辅助实录)
人工智能·微信小程序·小程序
2503_928411561 天前
AI 行业正在重塑每个人的工作方式,而你需要一个更轻松的入口
人工智能·小程序
qq_433502182 天前
微信小程序更新机制踩坑记录:updateInfo 为什么总是读到旧数据?
微信小程序·小程序·notepad++
优雅的大白鹅2 天前
创建uniapp小程序
小程序·uni-app