uni-app 地图marker开启点聚合后 regionchange函数失效

uni-app 地图marker开启点聚合后 regionchange函数失效

开发环境 版本号 项目创建方式
Windows 3.1.2 HBuilderX

示例代码:

<template>  
    <view>  
        <map style="width: 100%; height:600rpx;" latitude="37.789845" longitude="112.566085" id="map1" :markers="cover" min-scale='9'  
        @markertap='markertap'  @regionchange='regionchange'   
        ></map>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                mapContext:"",  
                cover: [{  
                    "address": "山西省太原市小店区恒大绿洲46商铺1007、1008号商铺",  
                    "createTime": null,  
                    "distances": 0.27266858165625574,  
                    "id":1,  
                    "image": null,  
                    "lat": 37.789845,  
                    "lng": 112.566085,  
                    "pharmacyAreaLevelId": "5",  
                    "pharmacyCode": 101989,  
                    "pharmacyName": "益源恒大绿洲二店",  
                    "status": "OPEN",  
                    "workBeginTime": "09:17:24",  
                    "workEndTime": "18:17:27",  
                    "width": 30,  
                    "height": 35,  
                    "joinCluster": true,  
                    "latitude": 37.789845,  
                    "longitude": 112.566085,  
                    "title": "益源恒大绿洲二店",  
                    callout:{  
                            content:"益源恒大绿洲二店",  
                            textAlign:"center",  
                            borderRadius:15,  
                            padding:5,  
                            display:"BYCLICK"  
                    },  
                }, {  
                    "address": "山西省太原市体育南路210号龙海方舟花园住宅小区六号楼1001号",  
                    "createTime": null,  
                    "distances": 0.5282916221988558,  
                    "id": 2,  
                    "image": null,  
                    "lat": 37.783993,  
                    "lng": 112.570989,  
                    "pharmacyAreaLevelId": "6",  
                    "pharmacyCode": 101749,  
                    "pharmacyName": "益源龙海方舟店",  
                    "status": "OPEN",  
                    "workBeginTime": null,  
                    "workEndTime": null,  
                    "width": 20,  
                    "height": 23,  
                    "joinCluster": true,  
                    "latitude": 37.784293,  
                    "longitude": 112.570989,  
                    "title": "益源龙海方舟店",  
                    callout:{  
                            content:"益源龙海方舟店",  
                            textAlign:"center",  
                            borderRadius:15,  
                            padding:5,  
                            display:"BYCLICK"  
                    },  
                },{  
                    "address": "山西省太原市小店区恒大绿洲46商铺1007、1008号商铺",  
                    "createTime": null,  
                    "distances": 0.27266858165625574,  
                    "id":3,  
                    "image": null,  
                    "lat": 37.789845,  
                    "lng": 112.566085,  
                    "pharmacyAreaLevelId": "5",  
                    "pharmacyCode": 101989,  
                    "pharmacyName": "益源恒大绿洲二店",  
                    "status": "OPEN",  
                    "workBeginTime": "09:17:24",  
                    "workEndTime": "18:17:27",  
                    "width": 30,  
                    "height": 35,  
                    "joinCluster": true,  
                    "latitude": 37.785545,  
                    "longitude": 112.566085,  
                    "title": "益源恒大绿洲二店",  
                    callout:{  
                            content:"益源恒大绿洲二店",  
                            textAlign:"center",  
                            borderRadius:15,  
                            padding:5,  
                            display:"BYCLICK"  
                    },  
                }, {  
                    "address": "山西省太原市体育南路210号龙海方舟花园住宅小区六号楼1001号",  
                    "createTime": null,  
                    "distances": 0.5282916221988558,  
                    "id": 4,  
                    "image": null,  
                    "lat": 37.783993,  
                    "lng": 112.570989,  
                    "pharmacyAreaLevelId": "6",  
                    "pharmacyCode": 101749,  
                    "pharmacyName": "益源龙海方舟店",  
                    "status": "OPEN",  
                    "workBeginTime": null,  
                    "workEndTime": null,  
                    "width": 20,  
                    "height": 23,  
                    "joinCluster": true,  
                    "latitude": 37.783193,  
                    "longitude": 112.570989,  
                    "title": "益源龙海方舟店",  
                    callout:{  
                            content:"益源龙海方舟店",  
                            textAlign:"center",  
                            borderRadius:15,  
                            padding:5,  
                            display:"BYCLICK"  
                    },  
                },{  
                    "address": "山西省太原市小店区恒大绿洲46商铺1007、1008号商铺",  
                    "createTime": null,  
                    "distances": 0.27266858165625574,  
                    "id": 5,  
                    "image": null,  
                    "lat": 37.789845,  
                    "lng": 112.566085,  
                    "pharmacyAreaLevelId": "5",  
                    "pharmacyCode": 101989,  
                    "pharmacyName": "益源恒大绿洲二店",  
                    "status": "OPEN",  
                    "workBeginTime": "09:17:24",  
                    "workEndTime": "18:17:27",  
                    "width": 30,  
                    "height": 35,  
                    "joinCluster": true,  
                    "latitude": 37.786745,  
                    "longitude": 112.566085,  
                    "title": "益源恒大绿洲二店",  
                    callout:{  
                            content:"益源恒大绿洲二店",  
                            textAlign:"center",  
                            borderRadius:15,  
                            padding:5,  
                            display:"BYCLICK"  
                    },  
                },],  
            }  
        },  
        onLoad() {  
            this.mapContext =  uni.createMapContext("map1",this)   
        },  
        methods: {  
            //当地图视野发生变化  
            regionchange(e){  
                console.log('regionchange触发')  
            },  
            markertap(){  
                console.log("markertap触发")  
            }  
        }  
    }  
</script>  

操作步骤:

  • 地图上有10个marker标记点,当将10个标记点的joinCluster改为true时

预期结果:

  • 当joinCluster为true时,当我拖动地图,缩放地图的时候,regionchange函数应该正确触发,点击标记点,markerTap函数应该触发
  • 控制台应该会输出:'regionchange触发’和"markertap触发"

实际结果:

  • regionchange函数没有触发,markerTap函数没有触发

更多关于uni-app 地图marker开启点聚合后 regionchange函数失效的实战教程也可以访问 https://www.itying.com/category-93-b0.html

5 回复

有没有人啊

更多关于uni-app 地图marker开启点聚合后 regionchange函数失效的实战教程也可以访问 https://www.itying.com/category-93-b0.html


开启点聚合之后,连@markertap事件也失效了,都失效了 有没有人解决一下啊

问题已确认

还有我想提个问题,点聚合的样式能不能自定义呀,现在只能蓝底白字

已加分,感谢您的反馈!

回到顶部