4***@qq.com
4***@qq.com
  • 发布:2020-07-15 22:51
  • 更新:2023-11-29 14:36
  • 阅读:1863

【报Bug】uni.createMapContext('mapId', this).moveToLocation() 地图界面无法平移到指定中心点

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 2.7.14

手机系统: iOS

手机系统版本号: iOS 13.4

手机厂商: 苹果

手机机型: iPhone8

页面类型: nvue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

uni.createMapContext('mapId', this).moveToLocation({
//这里指定经纬度中心点
longitude: 116.353304,
latitude: 39.908316,
success: function (res) {
console.log('纬度:' + res.latitude);
console.log('经度:' + res.longitude);
}
});

操作步骤:
uni.createMapContext('mapId', this).moveToLocation({  
                               //这里指定经纬度中心点  
                longitude: 116.353304,  
                latitude: 39.908316,  
                success: function (res) {  
                    console.log('纬度:' + res.latitude);  
                    console.log('经度:' + res.longitude);  
                }  
            });

预期结果:

定位到指定中心点

实际结果:

定位到当前地址中心点

bug描述:

官方API: uni.createMapContext(mapId,this) 中的方法 moveToLocation(),填写经纬度访问,最终结果地图界面 没有 平移到指定的经纬度中心点, 而是平移到当前地址定位的中心点.

2020-07-15 22:51 负责人:DCloud_uniAD_HDX 分享
已邀请:
4***@qq.com

4***@qq.com (作者)

请官方回复啊!

DCloud_uniAD_HDX

DCloud_uniAD_HDX

请提供模板代码?

  • 4***@qq.com (作者)

    https://ask.dcloud.net.cn/question/101855

    或者如楼下测试代码!

    2020-07-18 11:52

4***@qq.com

4***@qq.com (作者)

<template>  
    <view>  
        <map id="test_map" style="width: 750rpx; height: 300px;" :show-location="true"   
            :longitude="map.longitude" :latitude="map.latitude">  
        </map>  
        <button @click="dingwei">定位到"北京西站"</button>  
    </view>  
</template>  

<script>  
export default {  
    data() {  
        return {  
            map: {  
                longitude: '',//经度  
                latitude: '',//纬度  
            }  
        }  
    },  
    onLoad() {  
        let _this = this;  
        uni.getLocation({  
            type: 'gcj02',  
            success: function (res) {  
                _this.map.longitude = res.longitude;  
                _this.map.latitude = res.latitude;  
            }  
        });  
    },  
    methods: {  
        dingwei(){  
            //官方API uni.createMapContext(mapId,this)  
            //其中API对应方法之一: moveToLocation(OBJECT) //将地图中心移动到当前定位点,需要配合map组件的show-location使用  

            //需要实现的目标:定位平移 到指定坐标位置.比如案例中定位到"北京西站"  
            //实际结果: 在iPhone8中,定位平移 到本人真实的当前位置  

            uni.createMapContext('test_map', this).moveToLocation({  
                //该固定坐标为高德地图拾取,位置:北京西站  
                latitude: 39.894589,  
                longitude: 116.32125,  
                success: function(res){  
                    console.log("此处无回调!!!本条信息未在控制台打印");  
                    console.log(res);  
                }  
            });  
        }  
    }  
}  
</script>  

<style scoped>  
</style>
DCloud_uniAD_HDX

DCloud_uniAD_HDX

nvue 有问题,vue 正常,新增功能时漏掉了

  • 4***@qq.com (作者)

    OK,尽快处理!

    2020-07-20 11:40

  • uclort

    请问这个问题是不是还没有解决,nvue Android 也是 moveToLocation 无效。

    2020-08-02 18:15

  • 1***@qq.com

    回复 uclort: 对的,我现在就是不行的。没有回调

    2020-08-10 16:50

DCloud_uniAD_HDX

DCloud_uniAD_HDX

更新HBuilderX 2.8.3+ 已修复

  • 4***@qq.com (作者)

    2.8.2.20200726 修复相关如下:



    • App-iOS平台 修复 nvue map 组件 moveToLocation 方法不触发回调的Bug 详情


    在这个版本说明中只修复了 moveToLocation 方法不触发回调的Bug , 没有修复 平移到指定经纬度的bug,现在我iPhone8 上仍旧是平移到当前位置,我需要的是平移到我指定的经纬度的位置!现在我的HBX版本为2.8.3+ 需要卸载HBX重新安装HBX? 手机上已经卸载重装了HBX基座!

    2020-08-04 11:42

  • 4***@qq.com (作者)

    相当于bug未修复!或者是你们基座未更新?

    2020-08-04 11:43

  • 9***@qq.com

    回复 4***@qq.com: 大佬 解决没啊 我也出现这样的问题 调用不了 moveToLocation 我HBX都2.8.8.20200820 还是不行

    2020-08-27 16:40

DCloud_uniAD_HDX

DCloud_uniAD_HDX

验证下

<template>  
  <view>  
    <map id="test_map" ref="map1" style="width: 750rpx; height: 300px;" :show-location="true" :longitude="map.longitude"  
      :latitude="map.latitude">  
    </map>  
    <button @click="dingwei">定位到"北京西站"</button>  
    <button @click="dingwei2">ref 定位到"北京西站"</button>  
  </view>  
</template>  

<script>  
  export default {  
    data() {  
      return {  
        map: {  
          longitude: '', //经度  
          latitude: '', //纬度  
        }  
      }  
    },  
    onLoad() {  
      let _this = this;  
      uni.getLocation({  
        type: 'gcj02',  
        success: function(res) {  
          _this.map.longitude = res.longitude;  
          _this.map.latitude = res.latitude;  
        }  
      });  
    },  
    onReady() {  
      this.mapContext = uni.createMapContext('test_map', this);  
    },  
    methods: {  
      dingwei() {  
        //官方API uni.createMapContext(mapId,this)    
        //其中API对应方法之一: moveToLocation(OBJECT) //将地图中心移动到当前定位点,需要配合map组件的show-location使用    

        //需要实现的目标:定位平移 到指定坐标位置.比如案例中定位到"北京西站"    
        //实际结果: 在iPhone8中,定位平移 到本人真实的当前位置    

        this.mapContext.moveToLocation({  
          //该固定坐标为高德地图拾取,位置:北京西站    
          latitude: 39.894589,  
          longitude: 116.32125,  
          success: function(res) {  
            console.log("此处无回调!!!本条信息未在控制台打印");  
            console.log(res);  
          }  
        });  
      },  
      dingwei2() {  
        this.$refs.map1.moveToLocation({  
            //该固定坐标为高德地图拾取,位置:北京西站    
            latitude: 39.894589,  
            longitude: 116.32125  
          },  
          function(res) {  
            console.log("此处无回调!!!本条信息未在控制台打印");  
            console.log(res);  
          }  
        );  
      }  
    }  
  }  
</script>  

<style>  
</style>  
  • 4***@qq.com (作者)

    this.mapContext.moveToLocation(Object) 通过 this.mapContext 调用仍然无效

    this.$refs.map1.moveToLocation(Object) 通过 ref 方式没问题

    至少可以先用 ref 方式,谢谢!

    2020-08-07 13:47

  • DCloud_uniAD_HDX

    回复 4***@qq.com: 确定更到最新版本 2.8.3 了吗?

    2020-08-08 11:06

  • 4***@qq.com (作者)

    回复 DCloud_uniAD_HDX: 确定的, 2.8.3.20200728

    2020-08-10 09:47

  • 1***@qq.com

    回复 DCloud_uniAD_HDX: 更新到2.8.11了,moveToLocation在iOS端可以使用,在Android端有问题

    2020-09-16 09:56

ddpapa

ddpapa

大佬们,Android端的这个moveToLocation好使了吗,为啥我这还是不好使

9***@qq.com

9***@qq.com

nvue 这个bug在安卓还没修复吗?3年了呀 这么严重的问题

要回复问题请先登录注册