曹大宝
曹大宝
  • 发布:2020-09-11 15:40
  • 更新:2022-09-27 10:46
  • 阅读:923

【报Bug】nvue页面getCenterLocation方法无回调

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 2.8.11

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: magic TNY-AL00

页面类型: nvue

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

.

预期结果:

获取到当前地图中心点坐标

实际结果:

无回调

bug描述:

nvue页面getCenterLocation方法无回调

2020-09-11 15:40 负责人:DCloud_uni-ad_HDX 分享
已邀请:
DCloud_uni-ad_HDX

DCloud_uni-ad_HDX

验证没有问题,请提供测试代码

<template>  
  <view>  
    <map id="map1" class="map1" :show-location="true" :latitude="latitude" :longitude="longitude"></map>  
    <button @click="getCenterLocation">getCenterLocation</button>  
  </view>  
</template>  

<script>  
  export default {  
    data() {  
      return {  
        latitude: 39.925539,  
        longitude: 116.279037  
      }  
    },  
    onReady() {  
      this.mapContext = uni.createMapContext("map1", this);  
    },  
    methods: {  
      getCenterLocation() {  
        this.mapContext.getCenterLocation({  
          success: (res) => {  
            console.log("getCenterLocation");  
            console.log(res);  
          }  
        })  
      }  
    }  
  }  
</script>  

<style>  
  .map1 {  
    width: 750rpx;  
    height: 400px;  
  }  
</style>  
  • 曹大宝 (作者)


    <template>

    <view>

    <map :style="{width: map_width,height:map_height}"

    controls="controls"

    latitude="latitude"

    longitude="longitude"

    markers="covers"

    scale = "scale"

    polyline = "polyline"

    circles = "circles"
    enable-3D

    show-location

    id="map1"

    ref = "map1"

    show-location="true"
    @regionchange = "regionchange"

    @markertap = "markertap"

    >

    <!-- @tap = "test" -->

    </map>

    </view>

    <script>

    const conf = uni.getStorageSync('conf');

    export default {

    components: {uniNavBar},

    data() {

    return {

    data:{},

    map_width:"",

    map_height:"",

    btn:"",

    id:0,

    controls: [],

    polyline:[],

    circles:[],

    scale:20,

    title:"map",

    latitude: 39.909,

    longitude: 116.39742,

    covers: [],

    statusBarHeight:"",

    detail:{},

    id:"map1",

    address:""

    }

    },

    methods: {

    regionchange(e){

    this.mapContext.getCenterLocation({

    success(res) {

    console.log(res);

    console.log(1234);

    },

    fail(err){

    console.log(err);

    console.log(12345);

    },

    complete(e) {

    console.log(3);

    console.log(123456);

    }

    })

    }

    },

    }

    </template>

    2020-09-16 11:25

曹大宝

曹大宝 (作者) - 嗷呜嗷呜嗷呜

<template>  
    <view>  
    <map :style="{width: map_width,height:map_height}"  
             :controls="controls"   
             :latitude="latitude"   
             :longitude="longitude"   
             :markers="covers"  
             :scale = "scale"  
             :polyline = "polyline"  
             :circles = "circles"  
             enable-3D  
             show-location  
             id="map1"  
             ref = "map1"  
             :show-location="true"  
             @regionchange = "regionchange"  
             @markertap = "markertap"  
             >  
            <!-- @tap = "test" -->  
        </map>    
    </view>  
<script>  
    const conf = uni.getStorageSync('conf');  
    export default {  
            components: {uniNavBar},  
        data() {  
            return {  
                data:{},  
                map_width:"",  
                map_height:"",  
                btn:"",  
                id:0,  
                controls: [],  
                polyline:[],  
                circles:[],  
                scale:20,  
                title:"map",  
                latitude: 39.909,  
                longitude: 116.39742,  
                covers: [],  
                statusBarHeight:"",  
                detail:{},  
                id:"map1",  
                address:""  
            }  
        },  
        methods: {  
            regionchange(e){  
                this.mapContext.getCenterLocation({  
                        success(res) {  
                            console.log(res);  
                            console.log(1234);  
                        },  
                        fail(err){  
                            console.log(err);  
                            console.log(12345);  
                        },  
                        complete(e) {  
                            console.log(3);  
                            console.log(123456);  
                        }  
                })  
            }  
        },  
    }  
</template>
2***@qq.com

2***@qq.com

this.mapCtx.getCenterLocation(function(res){
console.log(res);
});
nvue这样就行

7***@qq.com

7***@qq.com

getCenterLocation 的success 和 fail 都不执行

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