y***@163.com
y***@163.com
  • 发布:2020-03-09 14:46
  • 更新:2022-07-27 15:29
  • 阅读:1404

【报Bug】nvue下getRegion无效

分类:nvue

详细问题描述

[内容] nvue页面下map通过createMapContext获取对象,regoinchange触发时要通过getRegion获取当前地图范围,结果调用不了getRegion,该方法所有回调函数都是无效的

重现步骤

[步骤] createMapContext获取地图对象,map触发regoinchange时调用getRegion触发success回调获取当前map范围坐标

[结果] getRegion的所有回调函数均不触发,且无报错

[期望]

[如果语言难以表述清晰,拍一个视频或截图,有图有真相]

IDE运行环境说明

[HBuilder 或 HBuilderX。如果你用其他工具开发uni-app,也需要在此说明] HBuilderX

[IDE版本号] 2.6.3.20200305-alpha

[windows版本号] win10企业版1703

[mac版本号]

uni-app运行环境说明

[运行端是h5或app或某个小程序?] app

[运行端版本号] 编译器版本:2.6.3(v3)

[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试] HBuilderX

[编译模式是老模板模式还是新的自定义组件模式?] 自定义组件模式

App运行环境说明

[Android版本号]

[iOS版本号] 13.3.1

[手机型号] iPhone X 国行

[模拟器型号]

附件

[IDE问题请提供HBuilderX运行日志。菜单帮助-查看运行日志,点右键打开文件所在目录,将log文件压缩成zip包上传] log.zip

[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]

[App安装包或H5地址]

[可重现代码片段]

<template>
<view>
<map class="map" id="map" :style="{'width': width, 'height': height}" :longitude="longitude" :latitude="latitude"
show-location="true" v-if="mode == 'map'" @regionchange="regionChange">
<div class="map-icon" v-bind:style="mapIconList" @click="getList">
<image class="map-icon-img" src="../../static/image/icon_liebiao_201808141348.png"></image>
</div>
<div class="map-icon" v-bind:style="mapIconLocate" @click="getLocation">
<image class="map-icon-img" src="../../static/image/icon_dingwei_201808141348.png"></image>
</div>
<div class="map-icon" v-bind:style="mapIconService">
<image class="map-icon-img" src="../../static/image/icon_kefu_201808141348.png"></image>
</div>
</map>
<div class="list" :style="{'width': width, 'height': height}" v-if="mode == 'list'">
<div class="map-icon" v-bind:style="mapIconList" @click="getMap">
<image class="map-icon-img" src="../../static/image/icon_ditu_201808141348.png"></image>
</div>
</div>
</view>
</template>

<script>
export default {
data() {
return {
width: '750rpx',
height: '750rpx',
statusBarHeight: 0,
mode: 'map',
longitude: 0,
latitude: 0,
mapCtx: null,
}
},
computed: {
mapIconList() {
return {
'left': '30rpx',
'bottom': this.statusBarHeight + 30 + 'rpx'
}
},
mapIconLocate() {
return {
'right': '30rpx',
'bottom': this.statusBarHeight + 30 + 'rpx'
}
},
mapIconService() {
return {
'right': '30rpx',
'bottom': this.statusBarHeight + 140 + 'rpx'
}
}
},
methods: {
getLocation: function() {
var that = this;
uni.getLocation({
type: 'gcj02',
geocode: true,
success: function(res) {
that.longitude = res.longitude;
that.latitude = res.latitude;
}
})
},
getList: function() {
var that = this;
that.mode = 'list';
},
getMap: function() {
var that = this;
that.mode = 'map';
},
regionChange: function(e) {
var that = this;
if (e.detail.type == 'end') {
that.mapCtx.getRegion({
success: function(res) {
console.log(res);
}
})
}
}
},
onLoad: function() {
//地图宽高
var that = this,
sys = uni.getSystemInfoSync();
that.width = sys.windowWidth 2 + 'rpx';
that.height = (sys.windowHeight - sys.statusBarHeight)
2 + 'rpx';
that.statusBarHeight = sys.statusBarHeight;

        //当前位置  
        that.getLocation();  
    },  
    mounted: function() {  
        this.mapCtx = uni.createMapContext('map', this);  
    }  
}  

</script>

<style>
.map-icon {
width: 90rpx;
height: 90rpx;
background-color: #F8F8F8;
border-radius: 26rpx;
border-color: rgba(0, 0, 0, 0.1);
border-width: 2rpx;
position: fixed;
}

.map-icon:active {  
    background-color: #e9e9e9;  
}  

.map-icon-img {  
    width: 78rpx;  
    height: 78rpx;  
    margin: 6rpx;  
}  

</style>

联系方式

[QQ] 375624193

2020-03-09 14:46 负责人:无 分享
已邀请:
DCloud_uniAD_HDX

DCloud_uniAD_HDX

Bug 已确认

DCloud_uniAD_HDX

DCloud_uniAD_HDX

HBuilderX 2.6.6+ 已修复

ddpapa

ddpapa

为嘛现在又不能用了,这个方法

羊虫

羊虫

现在这个方法又用不起了,hbuilderX版本 3.5.2.20220719-alpha

要回复问题请先登录注册