uni-app中marker数量超过18时 @markertap @callouttap事件失效

uni-app中marker数量超过18时 @markertap @callouttap事件失效

地图组件示例

<map id="myMap" class="myMap" :scale="scale" show-location show-compass :latitude="latitude"  
longitude="longitude" :markers="marks" :polygons="polygons" @tap="tap($event)"
style="'height:'+windowHeight*2+'rpx;'" [@markertap](/user/markertap)='toNavigation($event)' [@callouttap](/user/callouttap)="toNavigation($event)">
    <cover-view class="my_location">
        <cover-image class="img" src="@/static/image/locator.png" @click="pitch"></cover-image>
    </cover-view>
</map>  

```javascript
// 添加marker
getStationList() {  
    let token = uni.getStorageSync('token');  
    uni.request({  
        url: this.murl + '/screenDevice/selectDevice', // 请求接口    
        method: 'GET',  
        sslVerify: false,  
        data: {  
            type: '125'  
        },  
        header: {  
            'Authorization': 'Bearer ' + token,  
        },  
        success: (res) => {  
            console.log(res.data);  
            this.marks = []  
            this.mapContext.removeMarkers()  
            let list = res.data.data  
            this.ponits = list  
            let newmarkers = []  
            console.log(list)  
            for (var i = 0; i <20; i++) {  
                let marker = {  
                    latitude: list[i].lat, // 纬度  
                    longitude: list[i].lon, // 经度  
                    iconPath: '../../static/image/location.png',  
                    width: 20,  
                    height: 20,  
                    station_name: '',  
                    id: i+1,  
                    callout: {  
                        color: '#FFFFFF', // 文本颜色  
                        bgColor: '#FF8C00', // 背景色  
                        display: "ALWAYS", // 'BYCLICK':点击显示; 'ALWAYS':常显  
                        fontSize: 13,  
                        textAlign: 'center', // 文本对齐方式。有效值: left, right, center  
                        padding: 5, // 文本边缘留白  
                        borderRadius: 5,  
                        content: list[i].label,  
                    }  
                }  
                newmarkers.push(marker)  
            }  
            this.marks = newmarkers  
            console.log(this.marks)  
        },  
    });  
}

更多关于uni-app中marker数量超过18时 @markertap @callouttap事件失效的实战教程也可以访问 https://www.itying.com/category-93-b0.html

6 回复

界面 是 nvue

更多关于uni-app中marker数量超过18时 @markertap @callouttap事件失效的实战教程也可以访问 https://www.itying.com/category-93-b0.html


方便给我个demo。

怎么给你

刚刚发了界面的代码

这是界面的代码

我本地测试并没有复现你的问题,由于你使用了本地局域网的接口数据,我这边在你的demo基础上模拟了多个marker。

回到顶部