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>
相关推荐
search77 小时前
前端设计:CRG 3--CDC error
前端
治金的blog7 小时前
vben-admin和vite,ant-design-vue的结合的联系
前端·vscode
利刃大大8 小时前
【Vue】Vue2 和 Vue3 的区别
前端·javascript·vue.js
荔枝一杯酸牛奶9 小时前
HTML 表单与表格布局实战:两个经典作业案例详解
前端·html
Charlie_lll9 小时前
学习Three.js–纹理贴图(Texture)
前端·three.js
yuguo.im9 小时前
我开源了一个 GrapesJS 插件
前端·javascript·开源·grapesjs
安且惜9 小时前
带弹窗的页面--以表格形式展示
前端·javascript·vue.js
GISer_Jing11 小时前
AI驱动营销:业务技术栈实战(From AIGC,待总结)
前端·人工智能·aigc·reactjs
GIS之路12 小时前
GDAL 实现影像裁剪
前端·python·arcgis·信息可视化
AGMTI12 小时前
webSock动态注册消息回调函数功能实现
开发语言·前端·javascript