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

(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": "获取用户位置信息用于填写收货地址"
		}
      },
相关推荐
长沙三为智能科技4 小时前
家政小程序门店运营模块设计:会员、下单、派单、结算四段链路的落地拆解
python·小程序·内容运营
weixin_177297220696 小时前
回收小程序做自营还是撮合?先看你手里有什么
小程序
andrsted6 小时前
练题簿在线免费刷题:Word、PDF 导题与预览补全,把现成资料变成可练习题库
微信小程序·小程序·pdf·word·学习方法·刷题
AI行业应用研究6 小时前
会务信息载体的演进:纸质、PDF 与结构化数据源的分发成本与版本一致性
大数据·人工智能·安全·小程序·架构·pdf
Geek_Vison7 小时前
保险APP已经用了Flutter,还能接入小程序吗?
flutter·小程序·uni-app·mpaas·小程序容器
计算机毕设定制辅导-无忧学长8 小时前
《校园食堂在线订餐小程序的设计与实现》
java·vue.js·spring boot·微信小程序·uniapp·校园食堂在线订餐小程序
FX1317887KP_16 小时前
从KET到PET口语进阶:词汇量翻倍后,口语如何跟上?
小程序·ket口语·pet口语·fce备考·剑桥英语
m0_5873830017 小时前
工业场景设备维修维护实战技巧 全流程标准化落地与常见问题排查指南
java·spring·小程序·架构·需求分析
m0_587383002 天前
深圳 24 小时自助健身房系统软件开发实战指南与案例解析
java·spring boot·小程序·架构·需求分析