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

(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": "获取用户位置信息用于填写收货地址"
		}
      },
相关推荐
码云社区2 小时前
JAVA二手车交易二手车市场系统源码支持微信小程序+微信公众号+H5+APP
java·开发语言·微信小程序·二手交易·闲置回收
土土哥V_araolin6 小时前
多语言推三返一商城系统开发指南
小程序·零售
土土哥V_araolin8 小时前
一条线公排系统小程序开发
小程序·零售
爬坑的小白8 小时前
微信小程序拉起支付
微信小程序·小程序
土土哥V_araolin10 小时前
国械甄选新零售系统开发方案
小程序·个人开发·零售
humors22110 小时前
Deepseek工具:H5+Vue 项目转微信小程序报告生成工具
前端·vue.js·微信小程序·h5·工具·报告
毕设源码-钟学长12 小时前
【开题答辩全过程】以 基于微信小程序的蓝鲸旧物回收系统的设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
Greg_Zhong13 小时前
小程序中单元测试对比表单测试,及单元测试、表单测试、组件测试的底层实现原理
小程序·单元测试
sheji341613 小时前
【开题答辩全过程】以 基于微信小程序的考研服务平台为例,包含答辩的问题和答案
微信小程序·小程序
2501_9159184114 小时前
WebKit 抓包,WKWebView 请求的完整数据获取方法
android·前端·ios·小程序·uni-app·iphone·webkit