uniapp使用内置地图选择插件,实现地址选择并在地图上标点

2024-06-21 19:18

本文主要是介绍uniapp使用内置地图选择插件,实现地址选择并在地图上标点,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

uniapp使用内置地图选择插件,实现地址选择并在地图上标点

 

代码如下:

<style>page{ background:#F4F5F6; }::-webkit-scrollbar {width: 0;height: 0;color: transparent;}page{ height:100%; width:100%; font-size:24rpx;}image,view,input,textarea,label,text,navigator{ box-sizing: border-box; color:#222; font-size:28rpx;}image{width:100%; height:100%;}.line1{ white-space: nowrap;overflow: hidden; text-overflow: ellipsis;}.line2{ word-break: break-all; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }.flex{ display: flex; align-items: center;}.center{ display: flex; align-items: center; justify-content: center;}.between{ display: flex; align-items:center; justify-content: space-between;}.btn{ background:#f60; box-shadow: none; width:100%; text-align: center; line-height:92rpx; height:92rpx; border-radius:16rpx; color:#fff; border:0; font-size:32rpx;}.btn:active{ opacity:0.8;}.btn::after{display:none;}	
</style>
<style lang="scss" scoped>
.addaddress{ height:100%; overflow: hidden; .maps{ height:400rpx;}.box{padding:0 30rpx; position:relative; margin-top:-50rpx}.form{  background:#fff; border-radius:24rpx;&.f2{ margin-top:20rpx; }&.bd0{ border-bottom:0;}.item{ min-height:108rpx; padding:0 24rpx;			 .fl{ width:140rpx;}.fr{ flex:1; border-bottom:1px solid #F4F5F6; padding:40rpx 0;.yhname{}.area{padding-top:20rpx; color:#a5a5a5;}.loca{width:32rpx; height:32rpx; margin-right:8rpx;}.intxt{ flex:1; border:0; background:none;}.radios{.s1{margin-left:15rpx;}.radio{ transform: scale(0.65);}}}}.btn{ border-radius:48rpx; margin-top:90rpx;}}
}	
</style>
<template>
<view class="addaddress"><view class="maps"><map :longitude="longitude" :latitude="latitude" :scale="14" style="width:100%;height:100%;" :markers="markers"></map></view><view class="box"><view class="form"><view class="item flex" style="align-items: flex-start;"><view class="fl" style="padding:40rpx 0;">地址</view><view class="fr" @tap="chooseLocation"><view class="yhname flex"><input type="text" class="intxt" v-model="form.name" disabled placeholder="请选择地址" placeholder-style="color:#CBCBCB"><arrow-right :size="13" color="#CBCBCB"></arrow-right></view><view class="area" v-if="form.area">{{form.area}}</view></view></view><view class="item flex"><view class="fl">门牌号</view><view class="fr flex bd0"><input type="text" class="intxt" placeholder="街道、楼牌号等详细地址" placeholder-style="color:#CBCBCB"></view></view>		 </view><view class="form f2"><view class="item flex"><view class="fl">联系人</view><view class="fr between"><input type="text" class="intxt" placeholder="请输入联系人" placeholder-style="color:#CBCBCB"><view class="radios flex"><view class="s1 flex"><radio color="#4CD964" class="radio"></radio>先生</view><view class="s1 flex"><radio color="#4CD964" class="radio"></radio>女士</view></view></view></view><view class="item flex"><view class="fl">手机号</view><view class="fr flex"><input type="text" class="intxt" placeholder="联系人手机号码" placeholder-style="color:#CBCBCB"></view></view><view class="item"><button class="btn">保存</button></view></view></view>
</view>	
</template><script>export default{data(){return{longitude: 119.39742,latitude: 39.909,markers:[{longitude: 119.39742, latitude: 39.909,iconPath: '/static/address.png'}],form:{name:'',area:'',address:'',location:'',}}},onLoad() {this.$nextTick(res=>{			this.init()})},methods:{	//定位init(){uni.getLocation({type: 'wgs84',success:(res) => {if(res.errMsg=="getLocation:ok"){this.setMap(res)}}});},//自带选址chooseLocation() {uni.chooseLocation({success: (res) => {console.log(res)this.form.name = res.namethis.form.area = res.addressthis.form.location = this.util.formatLocation(res.longitude, res.latitude)this.setMap(res)}})},//设置地图坐标setMap(res){this.longitude = res.longitudethis.latitude  = res.latitudethis.markers[0].longitude =  res.longitudethis.markers[0].latitude  =  res.latitude}}}
</script><style>
</style>

这篇关于uniapp使用内置地图选择插件,实现地址选择并在地图上标点的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1082102

相关文章

Spring IoC 容器的使用详解(最新整理)

《SpringIoC容器的使用详解(最新整理)》文章介绍了Spring框架中的应用分层思想与IoC容器原理,通过分层解耦业务逻辑、数据访问等模块,IoC容器利用@Component注解管理Bean... 目录1. 应用分层2. IoC 的介绍3. IoC 容器的使用3.1. bean 的存储3.2. 方法注

MySQL中查找重复值的实现

《MySQL中查找重复值的实现》查找重复值是一项常见需求,比如在数据清理、数据分析、数据质量检查等场景下,我们常常需要找出表中某列或多列的重复值,具有一定的参考价值,感兴趣的可以了解一下... 目录技术背景实现步骤方法一:使用GROUP BY和HAVING子句方法二:仅返回重复值方法三:返回完整记录方法四:

Python内置函数之classmethod函数使用详解

《Python内置函数之classmethod函数使用详解》:本文主要介绍Python内置函数之classmethod函数使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录1. 类方法定义与基本语法2. 类方法 vs 实例方法 vs 静态方法3. 核心特性与用法(1编程客

IDEA中新建/切换Git分支的实现步骤

《IDEA中新建/切换Git分支的实现步骤》本文主要介绍了IDEA中新建/切换Git分支的实现步骤,通过菜单创建新分支并选择是否切换,创建后在Git详情或右键Checkout中切换分支,感兴趣的可以了... 前提:项目已被Git托管1、点击上方栏Git->NewBrancjsh...2、输入新的分支的

Linux中压缩、网络传输与系统监控工具的使用完整指南

《Linux中压缩、网络传输与系统监控工具的使用完整指南》在Linux系统管理中,压缩与传输工具是数据备份和远程协作的桥梁,而系统监控工具则是保障服务器稳定运行的眼睛,下面小编就来和大家详细介绍一下它... 目录引言一、压缩与解压:数据存储与传输的优化核心1. zip/unzip:通用压缩格式的便捷操作2.

Python实现对阿里云OSS对象存储的操作详解

《Python实现对阿里云OSS对象存储的操作详解》这篇文章主要为大家详细介绍了Python实现对阿里云OSS对象存储的操作相关知识,包括连接,上传,下载,列举等功能,感兴趣的小伙伴可以了解下... 目录一、直接使用代码二、详细使用1. 环境准备2. 初始化配置3. bucket配置创建4. 文件上传到os

关于集合与数组转换实现方法

《关于集合与数组转换实现方法》:本文主要介绍关于集合与数组转换实现方法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、Arrays.asList()1.1、方法作用1.2、内部实现1.3、修改元素的影响1.4、注意事项2、list.toArray()2.1、方

使用Python实现可恢复式多线程下载器

《使用Python实现可恢复式多线程下载器》在数字时代,大文件下载已成为日常操作,本文将手把手教你用Python打造专业级下载器,实现断点续传,多线程加速,速度限制等功能,感兴趣的小伙伴可以了解下... 目录一、智能续传:从崩溃边缘抢救进度二、多线程加速:榨干网络带宽三、速度控制:做网络的好邻居四、终端交互

Python中注释使用方法举例详解

《Python中注释使用方法举例详解》在Python编程语言中注释是必不可少的一部分,它有助于提高代码的可读性和维护性,:本文主要介绍Python中注释使用方法的相关资料,需要的朋友可以参考下... 目录一、前言二、什么是注释?示例:三、单行注释语法:以 China编程# 开头,后面的内容为注释内容示例:示例:四

java实现docker镜像上传到harbor仓库的方式

《java实现docker镜像上传到harbor仓库的方式》:本文主要介绍java实现docker镜像上传到harbor仓库的方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录1. 前 言2. 编写工具类2.1 引入依赖包2.2 使用当前服务器的docker环境推送镜像2.2