当前位置: 首页 > news >正文

uniapp App地图点击label

<template><uni-nav-bar backgroundColor="#fff" leftIcon="back" @clickLeft="back" :statusBar="true" title="本月签到轨迹" color="#333":border="false" /><view class="map-page"><map id="map" class="map" :latitude="mapLatitude" :longitude="mapLongitude" :markers="markers"@markertap="markertap" @tap="tapMap"></map></view></template><script setup>import {ref,onMounted,nextTick,} from 'vue';import {onUnload } from '@dcloudio/uni-app'import * as utils from '@/common/utils/back.js'import * as day from '@/common/utils/day.js'import hrUserSignInApi from '@/api/erp/hr/hrUserSignInApi.js'//存放标记点数组const markers = ref([])const mapLatitude = ref(null)const mapLongitude = ref(null)//以往记录const markersList = ref([])// 弹窗展示const isShow = ref(false)// 列表const recordList = ref([])// 设置图标const setMarkers = (latitude, longitude, id = 0) => {let len = recordList.value[id].locations.lengthlet location = {id,latitude: Number(latitude),longitude: Number(longitude),iconPath: '../../../static/workbenche/location.png',width: 10,height: 10,label: {content: `${len}次`}}markers.value.push(location)}// 获取记录const getMakers = () => {let options = {dateBegin: day.getFirstAndLastDayOfMonth().firstDayFormatted,dateEnd: day.getFirstAndLastDayOfMonth().lastDayFormatted}hrUserSignInApi.getCurrentUserSignInList(options).then(res => {if (res.ret) {let objMap = new Map()res.data.forEach(item => {item.fileDataJson = JSON.parse(item.fileDataJson)item.longitude = item.longitude.slice(0, 7)item.latitude = item.latitude.slice(0, 7)let key = `${item.longitude}-${item.latitude}`;if (objMap.has(key)) {objMap.get(key).push(item);} else {objMap.set(key, [item]);}});recordList.value = Array.from(objMap.values()).map((e, index) => {return {index,locations: e}})mapLatitude.value = recordList.value[0].locations[0].latitudemapLongitude.value = recordList.value[0].locations[0].longituderecordList.value.forEach(e => {e.locations.forEach(item => {setMarkers(item.latitude, item.longitude, e.index)})})} else {utils.showToast(res.message)}})}// 点击标记点const markertap = (e) => {let obj = recordList.value.find(item => item.index === e.detail.markerId)const subNVue = uni.getSubNVueById('popup');subNVue.show()uni.$emit('page-popup', obj.locations)}// 点击地图const tapMap = (e) => {let {longitude,latitude} = e.detailmapLatitude.value = latitudemapLongitude.value = longitude}onMounted(() => {getMakers()})onUnload(() => {uni.$off('page-popup')})const back = () => {uni.navigateBack()}
</script><style lang="scss" scoped>page {height: 100%;}.map-page {height: 100%;.map {width: 750rpx;height: 100%;}}
</style>

弹窗文件:使用nvue

<template><view class="content"><scroll-view scroll-y="true" class="scroll" :show-scrollbar="false"><view class="content-box"><view class="content-title f15">{{list[0]?.address}} | 签到{{list.length}}次</view><view class="content-body" v-for="(item,index) in list" :key="index"><view class="date"><text class="f14">时间 </text><text class="color-a1a3a5 f14">{{item.gmtCreated.slice(-14)}} </text></view><view class="img-list" v-if="item.imgList && item.imgList.length > 0"><text class="f14">照片</text><image class="img" :src="imgs" mode="" v-for="(imgs,imgIndex) in item.imgList" :key="imgIndex"@click="showImg(item.imgList,imgIndex)"></image></view><view class="desc" v-if="item.remark"><text class="f14">说明 </text><text class="desc-text color-a1a3a5 f14">{{item.remark}}</text></view><view class="liner" v-if="index !== list.length - 1"></view></view></view></scroll-view><view class="closeempty" @click="hidePopup"><uni-icons type="closeempty" color="#fff" size="20"></uni-icons></view></view>
</template><script>import {getImgUrl} from '@/common/utils/media.js'export default {onLoad() {uni.$on('page-popup', (event) => {event.forEach(e => {if (e.fileDataJson) {if (e.fileDataJson[0] && e.fileDataJson[0].uuids) {e.imgList = e.fileDataJson[0].uuids.map(item => {return getImgUrl(item);});} else {e.imgList = []}}})this.list = event})},data() {return {list: [],}},methods: {hidePopup() {const subNVue = uni.getSubNVueById('popup');subNVue.hide()},// 展示图片showImg(imgList, index) {uni.previewImage({urls: imgList,current: index})}}}
</script><style scoped>.content {position: fixed;top: 260%;left: 28%;}.scroll {width: 650rpx;border-radius: 10rpx;background-color: #fff;height: 600rpx;}.content-box {font-size: 12px;/* #ifndef APP-NVUE */box-sizing: border-box;/* #endif */padding: 20rpx;}.content-title {width: 600rpx;font-size: 15px;/* #ifndef APP-NVUE */white-space: normal;/* #endif */}.content-tip {position: absolute;right: 10px;bottom: 10px;color: #409EFF;}.date {width: 600rpx;margin: 10rpx 0;flex-direction: row;font-size: 30px;}.img-list {width: 600rpx;flex-direction: row;align-items: center;margin-bottom: 20rpx;}.img-text {font-size: 14px !important;}.img {width: 60rpx;height: 60rpx;border-radius: 10rpx;margin-left: 4rpx;}.liner {width: 600rpx;height: 1px;background-color: #f2F2F2;margin: 14rpx 0;}.desc {width: 600rpx;flex-direction: row;/* #ifndef APP-NVUE */white-space: normal;/* #endif */}.desc-text {width: 600rpx;/* #ifndef APP-NVUE */white-space: normal;/* #endif */}.closeempty {margin-top: 20rpx;}.color-a1a3a5 {color: #a1a3a5;}.f15 {font-size: 15px;}.f14 {font-size: 14px;}
</style>

pages.json

{"path": "hr/signIn/map/map","style": {"navigationStyle": "custom","navigationBarTextStyle": "black","app-plus": {"background": "transparent","scrollIndicator": "none","subNVues": [{"id": "popup","path": "hr/signIn/map/mapPopup","type": "popup","style": {"position": "popup","margin": "auto","width": "100%","height": "100%","background": "transparent"}}]}}},

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 在Stable Diffusion中驱动Tesla P40
  • <数据集>柑橘缺陷识别数据集<目标检测>
  • SQL注入实例(sqli-labs/less-8)
  • freeRTOS入门学习-基于STM32F103C8T6最小系统板-使用cubeMX创建一个新的工程
  • SpringBoot 框架学习笔记(七):Thymeleaf、拦截器 和 文件上传实现(解决了文件重名 和 按日期分目录存放问题)
  • Qt/C++最新地图组件发布/历时半年重构/同时支持各种地图内核/包括百度高德腾讯天地图
  • 大数据项目——广告数仓之HTTP概述
  • centos开启samba服务
  • flutter路由配置
  • 使用Python实现深度学习模型:智能垃圾分类与环境保护
  • Navicat—如何查看历史日志
  • 默认序列化会报警告Hessian/Burlap: calss is an unknown class in WebappClassLoader
  • [MRCTF2020]Ezpop
  • Linux驱动开发—设备树描述引脚复用 Pinmux 与Pinctrl
  • (24)(24.1) FPV和仿真的机载OSD(三)
  • 【前端学习】-粗谈选择器
  • iOS小技巧之UIImagePickerController实现头像选择
  • Iterator 和 for...of 循环
  • js
  • js继承的实现方法
  • MySQL QA
  • Protobuf3语言指南
  • Python实现BT种子转化为磁力链接【实战】
  • unity如何实现一个固定宽度的orthagraphic相机
  • VUE es6技巧写法(持续更新中~~~)
  • Xmanager 远程桌面 CentOS 7
  • 关于for循环的简单归纳
  • 诡异!React stopPropagation失灵
  • 聊聊springcloud的EurekaClientAutoConfiguration
  • 想晋级高级工程师只知道表面是不够的!Git内部原理介绍
  • 蚂蚁金服CTO程立:真正的技术革命才刚刚开始
  • ​LeetCode解法汇总1410. HTML 实体解析器
  • # 20155222 2016-2017-2 《Java程序设计》第5周学习总结
  • # 深度解析 Socket 与 WebSocket:原理、区别与应用
  • #70结构体案例1(导师,学生,成绩)
  • #LLM入门|Prompt#3.3_存储_Memory
  • (13)Hive调优——动态分区导致的小文件问题
  • (4)事件处理——(2)在页面加载的时候执行任务(Performing tasks on page load)...
  • (Charles)如何抓取手机http的报文
  • (C语言)逆序输出字符串
  • (Matalb分类预测)GA-BP遗传算法优化BP神经网络的多维分类预测
  • (阿里云在线播放)基于SpringBoot+Vue前后端分离的在线教育平台项目
  • (附源码)springboot金融新闻信息服务系统 毕业设计651450
  • (考研湖科大教书匠计算机网络)第一章概述-第五节1:计算机网络体系结构之分层思想和举例
  • (三) prometheus + grafana + alertmanager 配置Redis监控
  • (十八)三元表达式和列表解析
  • (算法)区间调度问题
  • (转)AS3正则:元子符,元序列,标志,数量表达符
  • .gitignore文件_Git:.gitignore
  • .net 流——流的类型体系简单介绍
  • .net中应用SQL缓存(实例使用)
  • /tmp目录下出现system-private文件夹解决方法
  • ?.的用法
  • @Slf4j idea标红Cannot resolve symbol ‘log‘
  • @SuppressWarnings(unchecked)代码的作用