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

(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 小时前
全渠道批发订货商城小程序管理系统
大数据·小程序
杰建云1679 小时前
多商家入驻小程序平台怎么做
人工智能·小程序
Giggle121814 小时前
开发上门维修(家政)小程序系统的核心功能和便捷方案
大数据·小程序
2501_9160088914 小时前
ChatGPT前端开发学习指南:Visual Studio Code与谷歌浏览器安装配置详解
ide·vscode·ios·小程序·uni-app·编辑器·iphone
杰建云16714 小时前
门店小程序怎么运营
大数据·小程序
万岳科技程序员小金14 小时前
2026互联网医院系统源码开发方案:APP+小程序+HIS一体化
小程序·互联网医院系统源码·医院app开发·医院软件开发·医疗陪诊小程序·医院平台开发·医院平台搭建
木风未来15 小时前
四川 APP 开发企业排名
小程序·app·软件开发·app开发
2501_9159090617 小时前
完整指南:如何将iOS应用上架到App Store
android·ios·小程序·https·uni-app·iphone·webview
matlabgoodboy1 天前
软件开发定制小程序APP帮代做java代码代编写C语言设计python编程
java·c语言·小程序
無名路人1 天前
uniApp 小程序 vue3 app.vue静默登录其他页面等待登录完成方式二
前端·微信小程序·ai编程