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

(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": "获取用户位置信息用于填写收货地址"
		}
      },
相关推荐
空中海6 小时前
微信小程序 - 03 工程实践层与综合 Demo
微信小程序·小程序·notepad++
小徐_23337 小时前
Wot UI v1 升级 v2?这份迁移指南帮你少踩坑!
前端·微信小程序·uni-app
优睿远行8 小时前
微信小程序云开发环境搭建与REST API混合架构实战
微信小程序·小程序
Greg_Zhong9 小时前
解决绘制的雷达图在页面有滚动时,雷达图出现`轻微上下偏移`的问题
微信小程序·canvans绘制雷达图
空中海9 小时前
微信小程序 - 02 基础概念层与核心能力层
微信小程序·小程序
無名路人11 小时前
小程序点餐页吸顶滚动
前端·微信小程序·ai编程
游戏开发爱好者812 小时前
使用Fiddler设置HTTPS抓包诊断Power Query网络问题
android·ios·小程序·https·uni-app·iphone·webview
七月的冰红茶12 小时前
【开发工具】使用cursor实现点单小程序
小程序
Greg_Zhong13 小时前
微信小程序中使用canvas实现雷达图及标签对角显示(实现雷达图标签的标准做法)
微信小程序·小程序canvas实现雷达图·标签不通过canvas绘制
码农客栈14 小时前
小程序学习(十八)之“骨架屏”
小程序