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

相关文章

Python实现图片分割的多种方法总结

《Python实现图片分割的多种方法总结》图片分割是图像处理中的一个重要任务,它的目标是将图像划分为多个区域或者对象,本文为大家整理了一些常用的分割方法,大家可以根据需求自行选择... 目录1. 基于传统图像处理的分割方法(1) 使用固定阈值分割图片(2) 自适应阈值分割(3) 使用图像边缘检测分割(4)

Android实现在线预览office文档的示例详解

《Android实现在线预览office文档的示例详解》在移动端展示在线Office文档(如Word、Excel、PPT)是一项常见需求,这篇文章为大家重点介绍了两种方案的实现方法,希望对大家有一定的... 目录一、项目概述二、相关技术知识三、实现思路3.1 方案一:WebView + Office Onl

C# foreach 循环中获取索引的实现方式

《C#foreach循环中获取索引的实现方式》:本文主要介绍C#foreach循环中获取索引的实现方式,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、手动维护索引变量二、LINQ Select + 元组解构三、扩展方法封装索引四、使用 for 循环替代

Spring Security+JWT如何实现前后端分离权限控制

《SpringSecurity+JWT如何实现前后端分离权限控制》本篇将手把手教你用SpringSecurity+JWT搭建一套完整的登录认证与权限控制体系,具有很好的参考价值,希望对大家... 目录Spring Security+JWT实现前后端分离权限控制实战一、为什么要用 JWT?二、JWT 基本结构

Java实现优雅日期处理的方案详解

《Java实现优雅日期处理的方案详解》在我们的日常工作中,需要经常处理各种格式,各种类似的的日期或者时间,下面我们就来看看如何使用java处理这样的日期问题吧,感兴趣的小伙伴可以跟随小编一起学习一下... 目录前言一、日期的坑1.1 日期格式化陷阱1.2 时区转换二、优雅方案的进阶之路2.1 线程安全重构2

Android实现两台手机屏幕共享和远程控制功能

《Android实现两台手机屏幕共享和远程控制功能》在远程协助、在线教学、技术支持等多种场景下,实时获得另一部移动设备的屏幕画面,并对其进行操作,具有极高的应用价值,本项目旨在实现两台Android手... 目录一、项目概述二、相关知识2.1 MediaProjection API2.2 Socket 网络

使用Python实现图像LBP特征提取的操作方法

《使用Python实现图像LBP特征提取的操作方法》LBP特征叫做局部二值模式,常用于纹理特征提取,并在纹理分类中具有较强的区分能力,本文给大家介绍了如何使用Python实现图像LBP特征提取的操作方... 目录一、LBP特征介绍二、LBP特征描述三、一些改进版本的LBP1.圆形LBP算子2.旋转不变的LB

Maven的使用和配置国内源的保姆级教程

《Maven的使用和配置国内源的保姆级教程》Maven是⼀个项目管理工具,基于POM(ProjectObjectModel,项目对象模型)的概念,Maven可以通过一小段描述信息来管理项目的构建,报告... 目录1. 什么是Maven?2.创建⼀个Maven项目3.Maven 核心功能4.使用Maven H

Redis消息队列实现异步秒杀功能

《Redis消息队列实现异步秒杀功能》在高并发场景下,为了提高秒杀业务的性能,可将部分工作交给Redis处理,并通过异步方式执行,Redis提供了多种数据结构来实现消息队列,总结三种,本文详细介绍Re... 目录1 Redis消息队列1.1 List 结构1.2 Pub/Sub 模式1.3 Stream 结

C# Where 泛型约束的实现

《C#Where泛型约束的实现》本文主要介绍了C#Where泛型约束的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录使用的对象约束分类where T : structwhere T : classwhere T : ne