时间点及网络状态 组件打点

效果如下:可根据自己的需求去调整,主要说一下实现思路和方法。

以下实现基于react语法去写的,vue或js逻辑类似,参考即可

主要思路:部分代码如下

1、良好、一般、糟糕 时间线的实现思路:

良好(现在看到的)lfDot,rgDot左右各一个点,鼠标滑过展示具体时间点信息

<div className="goodLine" style={{ left: actStartNode.left, width: actStartNode.width }}>
   <Tooltip title={formatMoment(actStartTime)}>
        <div className="lfDot"></div>
   </Tooltip>
   <Tooltip title={formatMoment(actEndTime)}>
         <div className="rgDot"></div>
   </Tooltip>
</div>

默认网络状态都是良好,如果有网络状态是一般或者糟糕的情况,继续创建一般的div或良好的div,动态设置left和width即可

<div className="badLine" style={{ left: '20%', width: '10%' }}></div> 

2、下面固定的刻度线

刻度线起装饰效果。scaleNum是 时间线总宽度/10px (timeLine.clientWidth / 10)

{/* 固定的刻度线 */}
<div className="scaleWrap">
    {new Array(scaleNum).fill({}).map((scaleItem: any, scaleIndex: number) => (
       <div className="scale" key={`scale_${scaleIndex}`}></div>
     ))}
</div>

3、封装提前进入、计划开始、计划结束、拖堂结束组件及打点到时间轴上

主要是计算当前元素的left,计算出位置,根据服务端返回的时间点来动态计算

total:即结束减开始的总数/100按照百分比来动态计算,resize也兼容

4、三角形具体打点

具体三角形的坐标点计算规则类似,获取left的值,动态设置css即可

交流


1、QQ群:可添加qq群共同进阶学习: 进军全栈工程师疑难解  群号:   856402057

2、公众号:公众号「进军全栈攻城狮」 ,对前端技术保持学习爱好者。我会经常分享自己所学所看的干货,在进阶的路上,共勉!通过公众号可加我vx拉群

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用uniapp内置的地图组件,通过监听地图点击事件来实现打点和弹窗功能。 首先,在`<template>`中添加地图组件: ```html <template> <view> <uni-mpvue-map :longitude="longitude" :latitude="latitude" @tap="onMapTap"> <uni-mpvue-map-marker v-for="(marker, index) in markers" :id="index" :longitude="marker.longitude" :latitude="marker.latitude" :title="marker.title" :iconPath="marker.iconPath" :label="marker.label" @tap="onMarkerTap"></uni-mpvue-map-marker> </uni-mpvue-map> </view> </template> ``` 其中,`longitude`和`latitude`为当前地图的中心点坐标。`markers`为已经打好的点的数组,`iconPath`为点的图标路径,`label`为点的标签。 然后,在`<script>`中添加以下代码: ```javascript export default { data() { return { longitude: 116.397389, latitude: 39.908860, markers: [ { longitude: 116.397389, latitude: 39.908860, title: '点1', iconPath: '/static/marker.png', label: { content: '标签1', color: '#ffffff', fontSize: 12, bgColor: '#000000', borderRadius: 3, padding: 5, textAlign: 'center' } }, { longitude: 116.407389, latitude: 39.908860, title: '点2', iconPath: '/static/marker.png', label: { content: '标签2', color: '#ffffff', fontSize: 12, bgColor: '#000000', borderRadius: 3, padding: 5, textAlign: 'center' } } ] } }, methods: { onMapTap(e) { const { longitude, latitude } = e.mp.detail this.markers.push({ longitude, latitude, title: '新点', iconPath: '/static/marker.png', label: { content: '新标签', color: '#ffffff', fontSize: 12, bgColor: '#000000', borderRadius: 3, padding: 5, textAlign: 'center' } }) }, onMarkerTap(e) { const { markerId } = e.mp.detail const marker = this.markers[markerId] uni.showModal({ title: marker.title, content: `经度:${marker.longitude},纬度:${marker.latitude}`, showCancel: false }) } } } ``` 在`onMapTap`函数中,通过`e.mp.detail`获取到点击的位置的经纬度,然后将该点信息添加到`markers`数组中,实现打点功能。 在`onMarkerTap`函数中,通过`e.mp.detail`获取到点击的点的`markerId`,然后根据`markerId`获取该点的信息,弹出该点的标题和经纬度的弹窗。 以上就是uniapp中使用地图组件打点并弹窗的实现方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值