在微信小程序实现轨迹回放的效果

1、wxml

<map id="map" longitude="{{longitude}}" latitude="{{latitude}}" scale="16"bindcontroltap="controltap"  bindmarkertap="markertap" markers="{{markers}}" polyline="{{polyline}}"bindregionchange="regionchange" show-location style="width: 100%; height:{{height}}px;" ></map><view class="padding flex flex-wrap justify-between align-center bg-white"><button  class='cu-btn bg-green shadow sm' bindtap='beginTrack'> 开始 </button><button  class='cu-btn bg-orange shadow sm' bindtap='pauseTrack'> 暂停 </button><button  class='cu-btn bg-red shadow sm' bindtap='endTrack'> 结束 </button></view>

2、js

//index.js
//获取应用实例
const app = getApp()Page({data: {StatusBar: app.globalData.StatusBar,CustomBar: app.globalData.CustomBar,height: wx.getSystemInfoSync().windowHeight,latitude: 0,longitude: 0,playIndex: 0,   timer: null,markers: [],polyline: [],pointsInfo:[]},regionchange(e) {//console.log(e.type)
  },markertap(e) {//console.log(e.markerId)
  },controltap(e) {//console.log(e.controlId)
  },beginTrack:function(e){},onLoad: function (options){var that = this;wx.request({url: 'http://**/getTrack',data: {  beginTime:"开始时间",endTime:"结束时间"},method: "post",success: function (res) {that.setData({pointsInfo:res.data.pointsInfos,polyline: [{points: res.data.points,color: "#FF0000DD",width: 4,dottedLine: true}],markers: [{iconPath: '../../img/location.jpg',id: 0,latitude: res.data.points[0].latitude,longitude: res.data.points[0].longitude,width: 30,height: 30,title: that.data.brandNumber,callout: {content: that.data.brandNumber + ' \n 时间:' + res.data.pointsInfos[0].create_time + ' \n 速度:' + res.data.pointsInfos[0].speed + ' km/h',color: "#000000",fontSize: 13,borderRadius: 2,bgColor: "#fff",display: "ALWAYS",boxShadow: "5px 5px 10px #aaa"}}],latitude: res.data.points[0].latitude,longitude: res.data.points[0].longitude,})}})},/*** 开始*/beginTrack:function(){var that = this;var i = that.data.playIndex == 0 ? 0 : that.data.playIndex;that.timer = setInterval(function () {i ++that.setData({playIndex: i,latitude: that.data.polyline[0].points[i].latitude,longitude: that.data.polyline[0].points[i].longitude,markers: [{iconPath: '../../img/car/e0.png',id: 0,latitude: that.data.polyline[0].points[i].latitude,longitude: that.data.polyline[0].points[i].longitude,width: 30,height: 30,title: that.data.brandNumber,callout: {content: that.data.brandNumber + ' \n 时间:' + that.data.pointsInfo[i].create_time + ' \n 速度:' + that.data.pointsInfo[i].speed + ' km/h',color: "#000000",fontSize: 13,borderRadius: 2,bgColor: "#fff",display: "ALWAYS",boxShadow: "5px 5px 10px #aaa"}}]}) if ((i+1) >= that.data.polyline[0].points.length) { that.endTrack();}}, 500) }, /*** 暂停*/pauseTrack:function(){var that = this;  clearInterval(this.timer)},/*** 结束*/endTrack:function(){var that = this; that.setData({playIndex: 0,latitude: that.data.polyline[0].points[0].latitude,longitude: that.data.polyline[0].points[0].longitude,markers: [{iconPath: '../../img/car/e0.png',id: 0,latitude: that.data.polyline[0].points[0].latitude,longitude: that.data.polyline[0].points[0].longitude,width: 30,height: 30,title: that.data.brandNumber,callout: {content: that.data.brandNumber + ' \n 时间:' + that.data.pointsInfo[0].create_time + ' \n 速度:' + that.data.pointsInfo[0].speed + ' km/h',color: "#000000",fontSize: 13,borderRadius: 2,bgColor: "#fff",display: "ALWAYS",boxShadow: "5px 5px 10px #aaa"}}]}) clearInterval(this.timer)}
})

后台数据使用的是百度鹰眼的数据。最终效果:

转载于:https://www.cnblogs.com/pengjf/p/10870021.html

微信小程序实现轨迹回放相关推荐

  1. [js] 微信小程序实现轨迹回放,微信原生小程序,基于uniapp的小程序?

    [js] 微信小程序实现轨迹回放,微信原生小程序,基于uniapp的小程序? 需要写出轨迹拖动,进度条,开始,暂停,结束功能. 个人简介 我是歌谣,欢迎和大家一起交流前后端知识.放弃很容易, 但坚持一 ...

  2. python实现轨迹回放供应_微信小程序实现轨迹回放

    //index.js//获取应用实例 const app =getApp() Page({ data: { StatusBar: app.globalData.StatusBar, CustomBar ...

  3. taro开发微信小程序-播放轨迹(十一)

    taro集成了地图后如何实现轨迹播放,暂停,停止呢?本身地图并不具备轨迹播放的能力,但是基于地图api可以实现轨迹播放的效果 思路如下: 1.获取所有的轨迹坐标点-最好是数组格式的json 2.定义一 ...

  4. 小程序实现轨迹回放代码

    小程序实现轨迹回放 以下只是实现轨迹回放的步骤和部分的主要代码,其他数据类的我就跳过了,我是用小程序的translateMarker方法来实现轨迹回放. 创建 map 上下文 MapContext 对 ...

  5. 微信小程序自动化测试——录制回放

    前文 微信小程序自动化测试--智能化 Monkey 提到Monkey虽然使用简单方便,但是不支持输入文本,页面逻辑校验等操作.如果用户希望做自动化回归测试,那么必然会涉及到逻辑相关校验点,这时候可以尝 ...

  6. 小程序 历史轨迹回放 地图播放历史轨迹

    先看效果图 html <map id='map' :latitude="addressInfo.latitude" :longitude="addressInfo. ...

  7. 微信小程序--行星轨迹

    效果展示 Demo代码 index.wxml <view id="container"><view id="sun"></view ...

  8. 微信小程序自动化测试——自定义测试(Minium)

    前文 微信小程序自动化测试--录制回放 提到录制回放 支持输入,文本查找,断言等自动化测试基础操作,无需编写代码,用例生成效率高,但是部分操作不支持,对复杂业务场景有局限性.如果用户希望适用复杂的业务 ...

  9. taro开发微信小程序-添加开发者预览,上传测试版本(十四)

    taro开发微信小程序,上传测试版本,如果需要访问网络需要打开调试模式,如果配置了https协议的服务,提示对应的服务器证书无效,那么必须正确配置ssl证书,可以在阿里云或者腾讯云申请. 添加开发者预 ...

最新文章

  1. 实现一个模拟CMD.exe命令编辑模式执行与显示的Delphi控件
  2. php yii2自动给值,Yii2基于Ajax自动获取表单数据的方法
  3. python dataframe 如何去除缺失值
  4. cstring查找子字符串_动态规划6:两个字符串的最长连续公共子串
  5. java 并发锁_Java并发教程–重入锁
  6. Python3小知识
  7. devops的重要性_为什么反馈而不是指标对DevOps至关重要
  8. jqGrid方法整理
  9. S32DS for PowrPC中对dcc编译器的支持
  10. 消息模板取数据的高阶使用说明
  11. 高德地图Amap绘制路线首尾相连问题
  12. 纯手工html+css实现静态游戏网首页(免费拿源码)
  13. 啤酒肚真的是喝啤酒引起的吗?
  14. ccf 智能运维 裴丹_智能运维是什么?
  15. 导入 xlsx php,php如何使用phpexcel类导入excel表格数据
  16. fastposter 2.2.0 新版本发布 电商级海报生成器
  17. zoj Heavy Cargo
  18. tensorflow框架精细讲解(一)
  19. Postman模拟接口API:接收请求报文equest,响应返回固定报文response
  20. 什么是门禁系统?门禁设备有哪些?

热门文章

  1. mvn exec运行java Main报错
  2. Jumpserver web界面跳板机
  3. iptables防火墙配置工具ShoreWall的安装和使用实例
  4. Foundation框架集合 ---- NSArray和NSMutableArray
  5. Unix 网络编程 读书笔记1
  6. VIM使用小技巧-重新载入文件
  7. jdi屏幕斜纹_荣耀V10屏幕有斜纹问题,有人甚至因此退货,真的这么严重?
  8. python方法大全参数是对象_向对象方法Python传递太多参数
  9. python处理word_python操作word,自动化办公
  10. java set中取数据_Java中取数据库用的ResultSet问题