亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

微信小程序?qū)崿F(xiàn)軌跡回放的示例代碼

 更新時(shí)間:2019年12月13日 10:24:04   作者:鋒子の日記  
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)軌跡回放的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

在微信小程序?qū)崿F(xiàn)軌跡回放的效果

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'> 結(jié)束 </button>
 </view>

2、js

//index.js
//獲取應(yīng)用實(shí)例
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:"開始時(shí)間",
    endTime:"結(jié)束時(shí)間"
   },
   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 時(shí)間:' + 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 時(shí)間:' + 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)
 },
 /**
  * 結(jié)束
  */
 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 時(shí)間:' + 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)
 }
})
 

后臺數(shù)據(jù)使用的是百度鷹眼的數(shù)據(jù)。最終效果:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • javascript 封裝的一個實(shí)用的焦點(diǎn)圖切換效果

    javascript 封裝的一個實(shí)用的焦點(diǎn)圖切換效果

    之前有一篇博客,實(shí)用的焦點(diǎn)圖切換效果,結(jié)構(gòu)行為相分離 解釋的比較詳細(xì),腳本是分離式的,但在易用性和重用性方面并不理想,這里原作者進(jìn)行了,優(yōu)化。
    2010-07-07
  • JS判斷不同分辨率調(diào)用不同的CSS樣式文件實(shí)現(xiàn)思路及測試代碼

    JS判斷不同分辨率調(diào)用不同的CSS樣式文件實(shí)現(xiàn)思路及測試代碼

    最近看一個網(wǎng)站,發(fā)現(xiàn)顯示器不同的分辨率,樣式文件調(diào)用的也不一樣,于是很好奇研究并寫了一個,經(jīng)測試感覺還不錯,感興趣的你可以來看看哦
    2013-01-01
  • 整理一些最近經(jīng)常遇到的前端面試題

    整理一些最近經(jīng)常遇到的前端面試題

    這篇文章主要給大家整理了一些在面試的時(shí)候經(jīng)常遇到的前端面試題,本文總結(jié)的這三十道面試題都是一些最近碰到的一些較為有用的前端題目,相信會對大家面試具有一定的參考價(jià)值,需要的朋友可以參考學(xué)習(xí),下面來一起看看吧。
    2017-04-04
  • JavaScript的原型繼承詳解

    JavaScript的原型繼承詳解

    這篇文章主要詳細(xì)介紹了JavaScript的原型繼承的相關(guān)資料,十分詳細(xì),需要的朋友可以參考下
    2015-02-02
  • 微信小程序下拉框功能的實(shí)例代碼

    微信小程序下拉框功能的實(shí)例代碼

    這篇文章主要介紹了微信小程序下拉框功能的實(shí)例代碼,代碼簡單易懂,非常不錯,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-11-11
  • javascript 網(wǎng)頁跳轉(zhuǎn)的方法

    javascript 網(wǎng)頁跳轉(zhuǎn)的方法

    昨天練習(xí)的時(shí)候正好要用到跳轉(zhuǎn)代碼,在網(wǎng)上找了一下,覺得下面幾個不錯...整理了一下發(fā)上來...
    2008-12-12
  • JavaScript中關(guān)于e.keycode的使用

    JavaScript中關(guān)于e.keycode的使用

    這篇文章主要介紹了JavaScript中關(guān)于e.keycode的使用方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • 利用JS實(shí)現(xiàn)二叉樹遍歷算法實(shí)例代碼

    利用JS實(shí)現(xiàn)二叉樹遍歷算法實(shí)例代碼

    眾所周知javascript語言中只提供了幾種基本類型的數(shù)據(jù)類型,而二叉樹是一種數(shù)據(jù)結(jié)構(gòu),在一些查詢等操作中能提供較好的性能,這篇文章主要給大家介紹了關(guān)于利用JS實(shí)現(xiàn)二叉樹遍歷算法的相關(guān)資料,需要的朋友可以參考下
    2021-11-11
  • ES6擴(kuò)展運(yùn)算符的使用方法示例

    ES6擴(kuò)展運(yùn)算符的使用方法示例

    es6新增加了一個運(yùn)算符,叫做擴(kuò)展運(yùn)算符,這個運(yùn)算符用在數(shù)組前面,會把數(shù)組展開變成各個獨(dú)立的值,這篇文章主要給大家介紹了關(guān)于ES6擴(kuò)展運(yùn)算符的相關(guān)資料,需要的朋友可以參考下
    2021-07-07
  • 關(guān)于js的事件循環(huán)機(jī)制剖析

    關(guān)于js的事件循環(huán)機(jī)制剖析

    JS事件循環(huán)機(jī)制,最常用到的地方應(yīng)該是做面試題,經(jīng)常給出一段代碼,讓你寫出console.log()順序,下面這篇文章主要給大家介紹了關(guān)于js事件循環(huán)機(jī)制的相關(guān)資料,需要的朋友可以參考下
    2021-06-06

最新評論