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>
相关推荐
FogLetter几秒前
初识图片懒加载:让网页像"懒人"一样聪明加载
前端·javascript
微客鸟窝2 分钟前
一文搞懂NVM管理Node.js:从安装到实战全攻略
前端
归于尽2 分钟前
Cookie、Session、JWT 的前世今生
前端
程序员辉哥4 分钟前
学会在Cursor中使用Rules生成代码后可以躺平了吗?
前端·后端
请你吃div8 分钟前
JavaScript 实用函数大全(超实用)
前端·javascript·面试
一个水瓶座程序猿.10 分钟前
Vue3 中使用 Vueuse
前端·javascript·vue.js
夏梦春蝉10 分钟前
ES6从入门到精通:Symbol与迭代器
前端·javascript·es6
一个水瓶座程序猿.14 分钟前
ES6数组的`flat()`和`flatMap()`函数用法
前端·ecmascript·es6
袁煦丞30 分钟前
AI直接出答案!Perplexica开源搜索引擎:cpolar内网穿透实验室第534个成功挑战
前端·程序员·远程工作
Hilaku32 分钟前
用“人话”讲明白10个最常用的正则表达式
前端·javascript·正则表达式