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

相关文章

C语言中联合体union的使用

本文编辑整理自: http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=179471 一、前言 “联合体”(union)与“结构体”(struct)有一些相似之处。但两者有本质上的不同。在结构体中,各成员有各自的内存空间, 一个结构变量的总长度是各成员长度之和。而在“联合”中,各成员共享一段内存空间, 一个联合变量

C++对象布局及多态实现探索之内存布局(整理的很多链接)

本文通过观察对象的内存布局,跟踪函数调用的汇编代码。分析了C++对象内存的布局情况,虚函数的执行方式,以及虚继承,等等 文章链接:http://dev.yesky.com/254/2191254.shtml      论C/C++函数间动态内存的传递 (2005-07-30)   当你涉及到C/C++的核心编程的时候,你会无止境地与内存管理打交道。 文章链接:http://dev.yesky

Tolua使用笔记(上)

目录   1.准备工作 2.运行例子 01.HelloWorld:在C#中,创建和销毁Lua虚拟机 和 简单调用。 02.ScriptsFromFile:在C#中,对一个lua文件的执行调用 03.CallLuaFunction:在C#中,对lua函数的操作 04.AccessingLuaVariables:在C#中,对lua变量的操作 05.LuaCoroutine:在Lua中,

uniapp接入微信小程序原生代码配置方案(优化版)

uniapp项目需要把微信小程序原生语法的功能代码嵌套过来,无需把原生代码转换为uniapp,可以配置拷贝的方式集成过来 1、拷贝代码包到src目录 2、vue.config.js中配置原生代码包直接拷贝到编译目录中 3、pages.json中配置分包目录,原生入口组件的路径 4、manifest.json中配置分包,使用原生组件 5、需要把原生代码包里的页面修改成组件的方

Vim使用基础篇

本文内容大部分来自 vimtutor,自带的教程的总结。在终端输入vimtutor 即可进入教程。 先总结一下,然后再分别介绍正常模式,插入模式,和可视模式三种模式下的命令。 目录 看完以后的汇总 1.正常模式(Normal模式) 1.移动光标 2.删除 3.【:】输入符 4.撤销 5.替换 6.重复命令【. ; ,】 7.复制粘贴 8.缩进 2.插入模式 INSERT

Lipowerline5.0 雷达电力应用软件下载使用

1.配网数据处理分析 针对配网线路点云数据,优化了分类算法,支持杆塔、导线、交跨线、建筑物、地面点和其他线路的自动分类;一键生成危险点报告和交跨报告;还能生成点云数据采集航线和自主巡检航线。 获取软件安装包联系邮箱:2895356150@qq.com,资源源于网络,本介绍用于学习使用,如有侵权请您联系删除! 2.新增快速版,简洁易上手 支持快速版和专业版切换使用,快速版界面简洁,保留主

如何免费的去使用connectedpapers?

免费使用connectedpapers 1. 打开谷歌浏览器2. 按住ctrl+shift+N,进入无痕模式3. 不需要登录(也就是访客模式)4. 两次用完,关闭无痕模式(继续重复步骤 2 - 4) 1. 打开谷歌浏览器 2. 按住ctrl+shift+N,进入无痕模式 输入网址:https://www.connectedpapers.com/ 3. 不需要登录(也就是

通过SSH隧道实现通过远程服务器上外网

搭建隧道 autossh -M 0 -f -D 1080 -C -N user1@remotehost##验证隧道是否生效,查看1080端口是否启动netstat -tuln | grep 1080## 测试ssh 隧道是否生效curl -x socks5h://127.0.0.1:1080 -I http://www.github.com 将autossh 设置为服务,隧道开机启动

(超详细)YOLOV7改进-Soft-NMS(支持多种IoU变种选择)

1.在until/general.py文件最后加上下面代码 2.在general.py里面找到这代码,修改这两个地方 3.之后直接运行即可

通过高德api查询所有店铺地址信息

通过高德api查询所有店铺地址电话信息 需求:通过高德api查询所有店铺地址信息需求分析具体实现1、申请高德appkey2、下载types city 字典值3、具体代码调用 需求:通过高德api查询所有店铺地址信息 需求分析 查询现有高德api发现现有接口关键字搜索API服务地址: https://developer.amap.com/api/webservice/gui