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

(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": "获取用户位置信息用于填写收货地址"
		}
      },
相关推荐
创了么OPC11 小时前
小程序能收款了,对公户还没开?独立开发者的交付闭环踩坑②
前端·微信小程序
一木 之林13 小时前
微信小程序开发全攻略·文章版|05 路由·交互·网络与音乐播放器实战
网络·微信小程序·小程序·交互
niucloud-admin14 小时前
NIUCLOUD LITE AI开发文档—模块开发:微信小程序
微信小程序·小程序·notepad++
weishuangyun119 小时前
家政上门预约小程序怎么做?本地家政接单系统搭建指南
小程序
举个栗子。19 小时前
443 条断言全绿,输入框却 9 次提交都不能用:一次关于「假护栏」的复盘
微信小程序·自动化·ai编程
andrsted20 小时前
练题簿在线免费刷题:将资料、Word 和 PDF导入小程序练习
学习·微信小程序·小程序·pdf·word·学习方法
txc1 天前
我用 AI 给两个人写了个微信小程序:共享清单、记账和纪念日
微信小程序
考拉讲支付2 天前
母婴亲子服务平台分账架构设计:多场景多方分账与合规清结算实践
大数据·运维·人工智能·微信小程序·架构·微信公众平台
拖孩2 天前
AI 帮我写的小程序「厨菜记」上线满月了,挣了两百块!!!
前端·后端·微信小程序