MapContext.translateMarker(Object object)取消旋转动画?
发布于 5 年前 作者 osong 3903 次浏览 来自 官方Issues

Page({

  data: {

    latitude: 34.617987,

    longitude: 112.455583,

    markers: [],

    addressData:['34.618058,112.455626', '34.617952,112.452407', '34.621378,112.452106', '34.621590,112.455368']

  },

  onReady: function (e) {

    this.mapCtx = wx.createMapContext('myMap');

    

    var markers = [];

    for(var i in this.data.addressData){

      var latitude = this.data.addressData[i].split(',')[0];

      var longitude = this.data.addressData[i].split(',')[1];

      var marker = {

        iconPath: '/image/location.png',

        latitude: latitude,

        longitude: longitude,

        title: i

      }

      markers.push(marker);

    }


    markers.push({

      iconPath: '/image/d1.png',

      width: "70px",

      height: "70px",

      id: 1,

      latitude: 34.618058,

      longitude: 112.455626,

      title: '需要移动的marker',

      anchor: {x: 0.5, y: 0.5} 

    });


    this.setData({

      markers: markers

    })

  },

  getCenterLocation: function () {

    this.mapCtx.getCenterLocation({

      success: function(res){

        console.log(res.longitude)

        console.log(res.latitude)

      }

    })

  },

  moveToLocation: function () {

    this.mapCtx.moveToLocation()

  },

  translateMarker: function(e) {

    var that = this;


    var index = e.target.dataset.index;

    var latitude = that.data.addressData[index].split(',')[0];

    var longitude = that.data.addressData[index].split(',')[1];


    this.mapCtx.translateMarker({

      markerId: 1,

      // autoRotate: true,

      duration: 100,

      rotate: 180,

      'rotate.duration': 0,

      destination: {

        latitude:latitude,

        longitude:longitude,

      },

      animationEnd() {

        console.log('animation end', new Date())

      },

      complete: function(){

        console.log('complete', new Date())

      }

    })

  },

  includePoints: function() {

    this.mapCtx.includePoints({

      padding: [10],

      points: [{

        latitude:23.10229,

        longitude:113.3345211,

      }, {

        latitude:23.00229,

        longitude:113.3345211,

      }]

    })

  }

})


以上是代码,我想在调用MapContext.translateMarker()时保留marker平移动画,取消其旋转动画

1 回复
回到顶部