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>
相关推荐
用户14125016652714 分钟前
一文彻底掌握 ECharts:从配置解读到实战应用
前端
LRH16 分钟前
React 架构设计:从 stack reconciler 到 fiber reconciler 的演进
前端
不一样的少年_19 分钟前
【前端效率工具】:告别右键另存,不到 50 行代码一键批量下载网页图片
前端·javascript·浏览器
golang学习记19 分钟前
从0死磕全栈之Next.js 企业级 next.config.js 配置详解:打造高性能、安全、可维护的中大型项目
前端
1024小神22 分钟前
next项目使用状态管理zustand说明
前端
Asort22 分钟前
JavaScript设计模式(八):组合模式(Composite)——构建灵活可扩展的树形对象结构
前端·javascript·设计模式
刘永胜是我24 分钟前
【iTerm2 实用技巧】解决两大顽疾:历史记录看不全 & 鼠标滚轮失灵
前端·iterm
returnfalse26 分钟前
🔥 解密StreamParser:让数据流解析变得如此优雅!
前端
凉城a26 分钟前
经常看到的IPv4、IPv6到底是什么?
前端·后端·tcp/ip
jserTang33 分钟前
Cursor Plan Mode:AI 终于知道先想后做了
前端·后端·cursor