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

(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": "获取用户位置信息用于填写收货地址"
		}
      },
相关推荐
laboratory agent开发3 小时前
2026小程序服务商推荐:全域私域数字化工具选型深度解析
小程序
小码哥06810 小时前
智慧物业管理系统开发详解:核心功能与源码开发优势
小程序·物业管理·物业系统
汤姆yu10 小时前
基于微信小程序的方言转文字小程序的设计与实现
java·小程序·毕业设计·方言翻译
不吃辣49010 小时前
vibe coding | 如何做一个 AI 闹钟小程序?
人工智能·小程序·ai编程
2501_915921431 天前
appuploader-cli 命令行上传 IPA 到 App Store Connect upload CI 集成
android·ci/cd·小程序·https·uni-app·iphone·webview
梦想的旅途21 天前
企业微信销售自动化:线索分配与超时预警
小程序·自动化·企业微信
单词记忆方法研究2 天前
探索上海背单词小程序品牌:高效学习工具的优化之路
大数据·学习·小程序
码上成长2 天前
小程序请求层怎么封装?
前端·小程序
万岳科技系统开发2 天前
医疗诊所小程序如何实现患者管理和会员运营?
java·小程序·apache
java1234_小锋2 天前
【免费】基于Python的微信小程序网约车(打车,在线叫车,移动出行)系统(FastAPI+Vue3) 锋哥原创出品,必属精品
微信小程序·小程序·fastapi·网约车系统·在线叫车系统