j***@163.com
j***@163.com
  • 发布:2020-10-23 14:58
  • 更新:2022-02-14 11:03
  • 阅读:1143

【报BUG】translateMarker在app-nvue中无效,微信小程序可以

分类:nvue

代码demo地址:https://github.com/asagcs/ceshi

我看文档上是这样写的:
translateMarker OBJECT 平移marker,带动画 app-nvue 2.1.5+、微信小程序带动画
改为vue则在小程序中可以随意跑。但是在app上不能使用。
另外,可以看到marker和定位偏差比较大。

我的代码:

<template>  
    <view class="wrapper">  
     <map class="mymap" id="trajectoryMapApp"  
        :latitude="latitude" :longitude="longitude"  
        :markers="markers"  
        :include-points="markers"  
        >  
      </map>  
      <view @tap="tapsdf">  
          <text>KSDFJAKSFDSFJ</text>  
      </view>  
     </view>  
</template>  

<script>      
import mqtt from "../../libs/mqtt.min.js";  
import { mapMutations } from "vuex";      
import ponits from '../../data/index.json';  

export default {  
  data() {  
    return {  
        markers: [{  
                id: 0,  
                latitude: "30.33943637197179",  
                longitude: '116.59881658661818',  
                iconPath: "/static/logo.png",  
                callout: {  
                  content: "333", // 车牌信息  
                  display: "BYCLICK",  
                  fontWeight: "bold",  
                  color: "#5A7BEE", //文本颜色  
                  fontSize: "12px",  
                  bgColor: "#ffffff", //背景色  
                  padding: 5, //文本边缘留白  
                  textAlign: "center",  
                },  

                width: 32,  
                height: 32  
            }],  
        index: 1,  
        latitude: '30.33943637197179',  
        longitude: '116.59881658661818'  
      }  
  },  

  created() {  

  },  

  methods: {  
    tapsdf: function() {  
        console.log("我要移动了")  
        let index = this.index;  
        var mapContext = uni.createMapContext("trajectoryMapApp", this);  
        let translateMarkerConfig = {  
           markerId: 0,  
           destination: {  
            longitude: ponits[index].longitude, // 车辆即将移动到的下一个点的经度  
            latitude:   ponits[index].latitude, // 车辆即将移动到的下一个点的纬度  
          },  
          duration: 100,  
          autoRotate: true,  
          success: (e) => {  
              console.log(e)  
          },  
          fail: (err) => {  
              console.log(err)  
          }  
        };  
        this.index +=1;  
        console.log(translateMarkerConfig)  

        mapContext.translateMarker(translateMarkerConfig);  
    }  
  },  

};  
</script>  

<style>  

    .wrapper {  
        display: flex;  
        flex: 1;  
    }  
        .mymap {  
            display: flex;  
            flex: 1;  
            height: 100vh;  
            width: 1005;  
        }  
</style>  
2020-10-23 14:58 负责人:无 分享
已邀请:
DCloud_iOS_XHY

DCloud_iOS_XHY

你好,使用的HX版本多少,哪个平台有问题?

  • j***@163.com (作者)

    正式版最新版:2.9.3.20201014

    在app平台有问题,marker不移动

    2020-10-26 08:40

  • j***@163.com (作者)

    android平台

    2020-10-26 08:43

j***@163.com

j***@163.com (作者)

已解决,问题同https://ask.dcloud.net.cn/people/DCloud_Android_ST

2***@qq.com

2***@qq.com

我也遇到了此类问题,请问大神是用什么方法解决的

shangrila

shangrila

autoRotate: true, marker没有自动旋转是怎么回事?

Hbuildex 3.3.11

app-nvue页面,autoRotate:true发现没有跟随polyline的方向而改变方向。
使用的地图是高德地图。

let _this = this;  
                _this.map.translateMarker({  
                    markerId: 1,  
                    autoRotate:true,  
                    // rotate: 30,  
                    destination: {  
                        longitude: datai.longitude, // 车辆即将移动到的下一个点的经度  
                        latitude: datai.latitude, // 车辆即将移动到的下一个点的纬度  
                    },  
                    duration: 700,  
                    animationEnd: function() {  
                        // 轨迹回放完成 处理H5端  
                        _this.playIndex++;  
                        if(_this.playIndex < len){  
                            _this.start(_this.playIndex, data);  
                        }else{  
                            console.log('okokok');  
                            uni.showToast({  
                                title: '播放完成',  
                                duration: 1400,  
                                icon: 'none'  
                            });  
                            _this.playIndex = 0;  
                            _this.isStart = false;  
                            _this.isDisabled = false;  
                        }  
                    },  
                    fail(e) {  
                        // 轨迹回放失败  
                    },  
                });

该问题目前已经被锁定, 无法添加新回复