uniapp使用uni.chooseLocation()打开地图选择位置

使用uni.chooseLocation()打开地址选择位置:

在Uniapp源码视图进行设置

添加这个属性:"requiredPrivateInfos":["chooseLocation"]

复制代码
</template>
	<view class="location_box">
		<view class="location_box_icon">
			<image src="../../static/weizhi.svg" mode=""></image>
			<view style="margin-top: 15px;">
				{{current_name}}
			</view>
		</view>
		<view class="current_location" @click="current">
			<view style="margin-top: 15px;width: 100%;">
				当前位置
			</view>
			<image src=" ../../static/shuxin.svg" mode="">
			</image>
		</view>
	</view>
<template>
 
<script>
    export default {
		data() {
			return {
                current_name: '',
 
            }
        },
        onLoad() {
    
 
        },
        methods: { 
               current() {
                        uni.chooseLocation({
	                        success: (res) => {
	                        	console.log('位置名称:' + res.name);
	                        	console.log('详细地址:' + res.address);
	                        	console.log('纬度:' + res.latitude);
	   	                        console.log('经度:' + res.longitude);
                                this.current_name = res.name
	                        }
                        });
                }
        }
}
</script>
相关推荐
子醉1 小时前
推荐一种适合前端开发使用的解决本地跨域问题的办法
前端
Niyy_1 小时前
前端一个工程构建多个项目,记录一次工程搭建
前端·javascript
xiangxiongfly9152 小时前
CSS link标签
前端·css
岁月宁静3 小时前
AI 多模态全栈应用项目描述
前端·vue.js·node.js
nn_(nana)3 小时前
修改文件权限--- chmod ,vi/vim,查看文件内容,yum-软件包管理器,systemctl管理系统服务
前端
2501_916008894 小时前
没有源码如何加密 IPA 实战流程与多工具组合落地指南
android·ios·小程序·https·uni-app·iphone·webview
烛阴4 小时前
从零开始掌握C#核心:变量与数据类型
前端·c#
han_4 小时前
前端高频面试题之Vuex篇
前端·vue.js·面试
qq_415216255 小时前
vue3搭建项目yarn+vue3+webpack+less+element-plus
前端·webpack·less