We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
//index.js //获取应用实例 const app = getApp() var isStrtaPoint = true; var point1 = { longitude: 113.26988, latitude: 23.135402 }; var point2 = { longitude: 113.27188, latitude: 23.135402 }; let markerId = 2222; var isPlay = false;// 是否在播放 Page({ data: { longitude: 113.27088, latitude: 23.135402, markers: [], polyline: [ { points: [ point1, point2 ], color: '#0976f2', width: 5 } ], }, onLoad: function () { this.mapCtx = wx.createMapContext('myMap'); let marker = {}; marker.id = markerId; marker.latitude = point1.latitude; marker.longitude = point1.longitude; marker.iconPath = '../../images/location.png' this.setData({ markers: [marker] }) console.log('YK写的'); console.log('YK写的2'); console.log('我再试一试YK'); console.log('KEN写的'); console.log('KEN写的2'); }, // 播放 或者 暂停 marker移动 click1:function(){ isPlay = !isPlay; if (isPlay){ this.playMarker(); } }, /** 打开这里的代码,就一切正常了 onHide:function(){ isPlay = false; }, */ // 界面跳转 click2: function () { wx.navigateTo({ url: '../next/next', }) }, // 播放 playMarker:function(){ let point = isStrtaPoint ? point2 : point1; this.mapCtx.translateMarker({ markerId: markerId, destination: { latitude: point.latitude, longitude: point.longitude, }, autoRotate: false, rotate: 0, duration: 1000, animationEnd: function () { console.log('marker end') }, fail: function (res) { console.log(res) } }) isStrtaPoint = !isStrtaPoint; var that = this; setTimeout(function () { if (isPlay) { that.playMarker() } }, 1000) } })
Activity
webVueBlog commentedon Mar 19, 2020