百度地图POI兴趣点查询

此篇博客介绍了如何通过JavaScript调用百度地图LocalSearch API,实现实时查询POI(Point of Interest)并在地图上显示,同时提供清除标记的功能。操作包括设置搜索框、触发搜索和清除地图覆盖物。
摘要由CSDN通过智能技术生成

比较简单,直接调用百度地图API

创建一个查询POI的方法:

        searchPOI(){
            //搜索框
            var local = new BMapGL.LocalSearch(map, {
                renderOptions:{map: map}
            });
            local.search(this.$refs.place.value);
        },

创建一个清除POI点的方法:

        clearMarker(){
            map.clearOverlays();
            this.$refs.place.value="";
        },

添加一个div:

    </div>
        <div class="info" id="r-result">景点查询:<input type="text" id="suggestId" size="20" value="景点" ref="place" style="width:150px;" /><button @click="searchPOI">查询</button><button @click="clearMarker">清除标记</button></div>
    </div>

css

#result{
        padding: 7px 10px;
        position: fixed;
        top: 15rem;
        left: 20px;
        width: 450px;
        background: #fff;
        box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
        border-radius: 7px;
        z-index: 99;
    }
    #result input{
        width:130px;
        margin-right:10px;
        height:25px;
        border: 1px solid rgba(27, 142, 236, 0.5);
        border-radius: 5px;
    }
    #result button{
        border: 1px solid rgba(27, 142, 236, 0.5);
        border-radius: 5px;
        background: rgba(27, 142, 236, 0.5);
        color: #fff
    }
    .info {
        z-index: 999;
        width: auto;
        min-width: 22rem;
        padding: .75rem 1.25rem;
        margin-left: 1.25rem;
        position: fixed;
        top: 10rem;
        background-color: #fff;
        border-radius: .25rem;
        font-size: 14px;
        color: #666;
        box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
    }
    #r-result button{
        border: 1px solid rgba(27, 142, 236, 0.5);
        border-radius: 5px;
        background: rgba(27, 142, 236, 0.5);
        color: #fff
    }

效果

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值