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>
相关推荐
袁煦丞11 分钟前
2025.8.18实验室【代码跑酷指南】Jupyter Notebook程序员的魔法本:cpolar内网穿透实验室第622个成功挑战
前端·程序员·远程工作
Joker Zxc16 分钟前
【前端基础】flex布局中使用`justify-content`后,最后一行的布局问题
前端·css
无奈何杨19 分钟前
风控系统事件分析中心,关联关系、排行、时间分布
前端·后端
Moment25 分钟前
nginx 如何配置防止慢速攻击 🤔🤔🤔
前端·后端·nginx
晓得迷路了30 分钟前
栗子前端技术周刊第 94 期 - React Native 0.81、jQuery 4.0.0 RC1、Bun v1.2.20...
前端·javascript·react.js
前端小巷子31 分钟前
Vue 自定义指令
前端·vue.js·面试
玲小珑37 分钟前
Next.js 教程系列(二十七)React Server Components (RSC) 与未来趋势
前端·next.js
Mike_jia38 分钟前
UptimeRobot API状态监控:零成本打造企业级业务健康看板
前端
江城开朗的豌豆38 分钟前
React状态更新踩坑记:我是这样优雅修改参数的
前端·javascript·react.js
CodeSheep1 小时前
Stack Overflow,轰然倒下了!
前端·后端·程序员