Jiang731619
Jiang731619
  • 发布:2019-12-23 14:41
  • 更新:2021-02-11 12:13
  • 阅读:1028

【报Bug】nvue页面的 map组件getScale获取地图缩放等级有问题

分类:uni-app

详细问题描述

(DCloud产品不会有明显的bug,所以你遇到的问题大都是在特定环境下才能重现的问题,请仔细描述你的环境和重现方式,否则DCloud很难排查解决你的问题)

[内容]
map组件getScale获取地图缩放等级有问题,比如我每次缩放地图后获取缩放等级,这个时候的值是错误的,然后要再拖动一下地图才能获取到正确的值

最新正式版HuilderX

安卓系统

<template>
<view>
<map id="myMap" :style="{height:height+'px'}" class="map" :latitude="lat" :longitude="lot" @regionchange="a" @callouttap="click" :markers="markers" :scale="mapscale" ></map>
</view>
</template>

<script>
export default {
data() {
return {
map:null,
mapscale:12,
lot:103.964068,
lat:30.674820,

            circles:[  
                {                         
                    latitude: 30.674820,  
                    longitude: 103.964068,  
                    fillColor: "#f70104",  
                    radius:1000,  
                    strokeWidth:0  
                }  
            ],  
            markers: [  
                {  
                    iconPath:'../../static/images/point.png',  
                    id: 1,  
                    latitude: 30.674820,  
                    longitude: 103.964068,                        
                    callout:{  
                        content:'青羊区\n68个合作社',  
                        color:'#ffffff',  
                        fontSize:'12',  
                        bgColor:'#f70104',  
                        padding:'8',  
                        borderRadius:'1000',  
                        textAlign:"center",  
                        display:"ALWAYS"  
                    }  

                },  

            ],  
        }             
    },  
    onLoad() {  
        let that=this;  
        uni.getSystemInfo({  
            success:function(res){  
                that.height=res.windowHeight  
            }  
        })  
    },  
    onReady() {  
        this.map=uni.createMapContext('myMap',this);  
    },  
    onShow() {  
        let that=this;  
    },  
    methods:{  

        click:function(e){  
            console.log(e)  
        },  

        a:function(e){  
            //console.log(e)  
            let that=this;                
            if(e.type=='end'){  
                console.log('end')  
                this.getMapScale()  

            }  

        },  
        getMapScale:function(){  
            let that=this;  

            this.map.getScale({  
                success:function(res){  
                    console.log(res.scale)  
                    //that.mapscale=res.scale  
                     if(res.scale>=13){  

                        that.markers=[  
                            {  
                                iconPath:'../../static/images/point.png',  
                                id: 1,  
                                latitude: 30.674820,  
                                longitude: 103.964068,                        
                                callout:{  
                                    content:'德天信合作社',  
                                    color:'#ffffff',  
                                    fontSize:'12',  
                                    bgColor:'#f70104',  
                                    padding:'8',  
                                    borderRadius:'1000',  
                                    textAlign:"center",  
                                    display:"ALWAYS"  
                                }              
                            },  
                        ]  

                    }else{  
                        that.markers=[  
                            {  
                                iconPath:'../../static/images/point.png',  
                                id: 1,  
                                latitude: 30.674820,  
                                longitude: 103.964068,                        
                                callout:{  
                                    content:'青羊区\n68个合作社',  
                                    color:'#ffffff',  
                                    fontSize:'12',  
                                    bgColor:'#f70104',  
                                    padding:'8',  
                                    borderRadius:'1000',  
                                    textAlign:"center",  
                                    display:"ALWAYS"  
                                }              
                            },  
                        ]  
                    }  
                }  
            })  
        }  
    }  
}  

</script>

<style lang="scss">
.map{width: 750rpx;}
</style>

联系方式

QQ:413171812

2019-12-23 14:41 负责人:DCloud_Android_ST 分享
已邀请:
大苏

大苏

现在任然存在这个问题

DCloud_Android_ST

DCloud_Android_ST

问题已确认

  • Jiang731619 (作者)

    一年了才确认

    2020-11-26 14:28

DCloud_Android_ST

DCloud_Android_ST

HX3.0.0+已修复该问题

  • gweii

    微信小程序里每次缩放地图后,要再拖动一下地图才能触发regionchange事件

    2021-02-12 17:55

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