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>
相关推荐
跟橙姐学代码12 分钟前
Python 类的正确打开方式:从新手到进阶的第一步
前端·python·ipython
Jagger_12 分钟前
SonarQube:提升代码质量的前后端解决方案
前端·后端·ai编程
Becauseofyou13715 分钟前
如果你刚入门Three.js,这几个开源项目值得你去学习
前端·three.js
菜市口的跳脚长颌16 分钟前
前端大文件上传全攻略(秒传、分片上传、断点续传、并发控制、进度展示)
前端
不一样的少年_18 分钟前
同事以为要重写,我8行代码让 Vue 2 公共组件跑进 Vue 3
前端·javascript·vue.js
云枫晖25 分钟前
JS核心知识-数据转换
前端·javascript
xuyanzhuqing25 分钟前
代码共享方案-多仓库合并单仓库
前端
RaidenLiu27 分钟前
Riverpod 3:重建控制的实践与性能优化指南
前端·flutter
学习中的小胖子27 分钟前
React的闭包陷阱
前端
不卷的攻城狮29 分钟前
【精通react】(五)react 函数时组件为什么需要 hooks?
前端