vue-baidu-map动态描点,点击展示点信息

html

<baidu-map class="bm-view" :center="center" :zoom="zoom" @ready="handler" :scroll-wheel-zoom="true">
                            <bm-marker v-for="(item,index) of pointList" :key="index" :position="item.markerPoint" :dragging="false" @click="infoWindowOpen(index,item)">
                                <bm-info-window :show="item.mapShow" @close="infoWindowClose(index,item)" @open="infoWindowOpen(index,item)">{{item.res}}</bm-info-window>
                            </bm-marker>
                        </baidu-map>

data

center: {
                lng: 104.06107,
                lat: 30.543327
            },
            zoom: 3,
            mapShow: false,
            pointList: [{
                    res: "家庭地址:XXXXXXXXXX",
                    markerPoint: {
                        lng: 104.06107,
                        lat: 30.543327
                    }
                },
                {
                    res: "签到位置:四川省成都市武侯区益州大道中段1800",
                    markerPoint: {
                        lng: 104.061855,
                        lat: 30.545336
                    }
                },
                {
                    res: "签退位置:四川省成都市武侯区益州大道中段1800",
                    markerPoint: {
                        lng: 104.061025,
                        lat: 30.545156
                    }
                }
            ]

js

handler({
            BMap,
            map
        }) {
            // console.log(BMap, map)
            // this.center.lng = 104.06107
            // this.center.lat = 30.543327
            this.center.lng =this.pointList[0].markerPoint.lng;
            this.center.lat=this.pointList[0].markerPoint.lat;
            this.zoom = 15
        },
        infoWindowClose(index,item) {
            // console.log(index,item)
            item.mapShow=false
            this.$set(this.pointList,index,item)
        },
        infoWindowOpen(index,item) {
            // console.log(index,item)
            item.mapShow=true
            this.$set(this.pointList,index,item)
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值