8***@qq.com
8***@qq.com
  • 发布:2022-04-14 19:13
  • 更新:2022-04-15 18:30
  • 阅读:1563

【报Bug】mapContext.addMarkers不生效

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 家庭中文版

HBuilderX类型: 正式

HBuilderX版本号: 3.3.13

手机系统: Android

手机系统版本号: Android 8.0

手机厂商: 小米

手机机型: MIX2

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

<template>
<view>
<map id="map1" ref="map1" class="map" v-if="isShowMap" :latitude="latitude" :longitude="longitude" :scale="scale"
@controltap="controltap" :show-location="true"></map>
<button @click="addMarkers">updateMarker</button>
</view>
</template>

<script>
export default {
data() {
return {
isShowMap: true,
latitude: 23.099994,
longitude: 113.324520,
scale: 7,
controls: [{
id: 1,
position: {
left: 15,
top: 15
},
iconPath: ../../static/images/map/dlsj-icon.png,
clickable: true
}]
}
},
onReady() {
this.mapContext = uni.createMapContext('map1', this);
this.mapContext.initMarkerCluster({
enableDefaultStyle: false,
zoomOnClick: true,
gridSize: 60,
complete(res) {
console.log('initMarkerCluster', res)
}
});

        this.mapContext.on("markerClusterCreate", (e) => {  
          console.log("markerClusterCreate", e);  
        });  
    },    
    methods: {    
        addMarkers() {  
          const marker = [{  
            id: 1,  
            iconPath: `../../static/images/map/dlsj-icon.png`,  
            latitude: 23.099994,  
            longitude: 113.324520,  
            width: 50,  
            height: 50,  
            joinCluster: true, // 指定了该参数才会参与聚合  
            label: {  
              width: 50,  
              height: 30,  
              borderWidth: 1,  
              borderRadius: 10,  
              bgColor: '#ffffff'  
            }  
          }];  
            this.mapContext.addMarkers({  
              markers: marker,  
              clear: false,  
              complete(res) {  
                console.log('addMarkers', res)  
              }  
            })  
        },  
    }    
}    

</script>

<style>
.map {
width: 750rpx;
height: 400px;
}
</style>

操作步骤:

点击updateMarker执行mapContext.addMarkers

预期结果:

可以正常执行mapContext.addMarkers

实际结果:

点击updateMarker执行mapContext.addMarkers不生效

bug描述:

mapContext.addMarkers不生效

2022-04-14 19:13 负责人:无 分享
已邀请:
8***@qq.com

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

<template>    
    <view>    
        <map id="map1" ref="map1" class="map" v-if="isShowMap" :latitude="latitude" :longitude="longitude" :scale="scale"   
         @controltap="controltap" :show-location="true"></map>    
        <button @click="addMarkers">updateMarker</button>    
    </view>    
</template>    

<script>    
    export default {    
        data() {    
            return {    
                isShowMap: true,    
                latitude: 23.099994,    
                longitude: 113.324520,    
                scale: 7,    
                controls: [{    
                    id: 1,    
                    position: {    
                        left: 15,    
                        top: 15    
                    },    
                    iconPath: `../../static/images/map/dlsj-icon.png`,    
                    clickable: true    
                }]    
            }    
        },    
        onReady() {    
            this.mapContext = uni.createMapContext('map1', this);    
            this.mapContext.initMarkerCluster({  
              enableDefaultStyle: false,  
              zoomOnClick: true,  
              gridSize: 60,  
              complete(res) {  
                console.log('initMarkerCluster', res)  
              }  
            });  

            this.mapContext.on("markerClusterCreate", (e) => {  
              console.log("markerClusterCreate", e);  
            });  
        },    
        methods: {    
            addMarkers() {  
              const marker = [{  
                id: 1,  
                iconPath: `../../static/images/map/dlsj-icon.png`,  
                latitude: 23.099994,  
                longitude: 113.324520,  
                width: 50,  
                height: 50,  
                joinCluster: true, // 指定了该参数才会参与聚合  
                label: {  
                  width: 50,  
                  height: 30,  
                  borderWidth: 1,  
                  borderRadius: 10,  
                  bgColor: '#ffffff'  
                }  
              }];  
                this.mapContext.addMarkers({  
                  markers: marker,  
                  clear: false,  
                  complete(res) {  
                    console.log('addMarkers', res)  
                  }  
                })  
            },  
        }    
    }    
</script>    

<style>    
    .map {    
        width: 750rpx;    
        height: 400px;    
    }    
</style>  
DCloud_UNI_Anne

DCloud_UNI_Anne

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