百度地图添加查询框

百度地图添加查询框_第1张图片

  
{{item.title}} {{item.address}}

        @keyup.enter.native="searchMap" 添加键盘回车监听事件 

 //查询
            searchMap() {
                let that = this
                that.isShow = true
                let ls = new BMapGL.LocalSearch(that.map)
                ls.setSearchCompleteCallback((rs) => {
                    this.searchFrom = rs._pois;
                })
                ls.search(this.area);
            },
          //查询后回显
            search(item) {
                this.initMap(item.point.lng, item.point.lat)
                this.isShow = false
                this.area = ''
            }

        再次初始化地图,实现地图切换,坐标点显示

initMap(longitude, latitude) {
                let that = this
                let size = 18;
                that.map = new BMapGL.Map("container");// 创建地图实例
                if (longitude == null || latitude == null) {
                    longitude = 111.1480354849708;
                    latitude = 37.5262978563336;
                    size = 16
                }
                let point = new BMapGL.Point(longitude, latitude);
                that.map.centerAndZoom(point, size);      // 初始化地图,设置中心点坐标和地图级别
                that.map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放
                this.drawInit()
                this.getEventListener()
            },

 

你可能感兴趣的:(vue.js,javascript,ecmascript)