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

(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": "获取用户位置信息用于填写收货地址"
		}
      },
相关推荐
兰亭妙微3 小时前
从线到机:AI 与多模态交互如何重塑 B 端与 App 界面设计
人工智能·小程序·交互·用户体验设计公司
青青子衿越3 小时前
微信小程序web-view嵌套H5,小程序与H5通信
前端·微信小程序·小程序
乔公子搬砖4 小时前
小程序开发提效:npm支持、Vant Weapp组件库与API Promise化(八)
前端·javascript·微信小程序·js·promise·vagrant·事件绑定
!win !8 小时前
uni-app支付宝端彻底禁掉下拉刷新效果
前端·小程序·uni-app
软希网分享源码13 小时前
校园跑腿小程序源码 | 跑腿便利店小程序(源码下载)
小程序·跑腿便利店小程序·校园跑腿小程序源码
说私域21 小时前
基于开源 AI 智能名片链动 2+1 模式 S2B2C 商城小程序的新开非连锁品牌店开业引流策略研究
人工智能·小程序·开源
KlDMEO1 天前
DrissionPage 能控制火狐或edge吗
其他·微信小程序·小程序
柯北(jvxiao)1 天前
爆肝三周,我终于上线了自己的第一个小程序
微信小程序·小程序
lumi.1 天前
2.3零基础玩转uni-app轮播图:从入门到精通 (咸虾米总结)
java·开发语言·前端·vue.js·微信小程序·uni-app·vue
weixin_177297220691 天前
剧本杀APP系统开发:打造多元化娱乐生态的先锋力量
小程序·娱乐·剧本杀