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

(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": "获取用户位置信息用于填写收货地址"
		}
      },
相关推荐
CRMEB8 小时前
不懂设计也能有精美商城?CRMEB 主题广场与可视化装修的“千店千面“实操
人工智能·ai·小程序·开源·php
维双云11 小时前
2026微信小程序开店用哪个平台?长期稳定运营的系统选择方法
微信小程序·小程序
Ai-_Man11 小时前
我是想导出豆包智能体的聊天记录,能分开用户和智能体对话吗?记录有点太多了
人工智能·ai·小程序
辛迪聊物业数字化12 小时前
【智能楼宇系统有什么用?赋能园区高效 节能 安全】
经验分享·安全·微信小程序·php
lhldsg12 小时前
家校托管互通系统开发实战:从需求分析到部署全指南
小程序·uni-app·需求分析
lhldsg13 小时前
家校托管互通系统技术架构与实战设计
java·经验分享·小程序·架构
疯狂小猫咪13 小时前
SaaS vs 定制开发:教培机构技术选型的成本、风险与适用场景深度对比
小程序
www_aiyuanma_vip14 小时前
非遗传承小程序
小程序
lhldsg14 小时前
线上住宿预约系统开发实战:从需求分析到接口设计
java·大数据·小程序·需求分析
mykj155116 小时前
一个小程序从想法到上线,需要经历哪些步骤
小程序·app开发·小程序开发