zoukankan      html  css  js  c++  java
  • vue百度地图插件

    安装

    npm i --save vue-baidu-map
    代码
    <template>
        <div>
            <baidu-map v-bind:style="mapStyle" class="bm-view" ak="你的百度地图ak" :center="center" :zoom="zoom" :scroll-wheel-zoom="true"
                    @click="getClickInfo" @moving="syncCenterAndZoom" @moveend="syncCenterAndZoom" @zoomend="syncCenterAndZoom">
                    <bm-view style=" 100%; height:500px;"></bm-view>
                    <bm-marker :position="{lng: center.lng, lat: center.lat}" :dragging="true" animation="BMAP_ANIMATION_BOUNCE">
                    </bm-marker>
                       <bm-control :offset="{ '10px', height: '10px'}">
                        <bm-auto-complete v-model="keyword" :sugStyle="{zIndex: 999999}">
                            <input type="text" placeholder="请输入搜索关键字" class="serachinput">
                        </bm-auto-complete>
                    </bm-control>    
                    <bm-local-search :keyword="keyword" :auto-viewport="true" style="0px;height:0px;overflow: hidden;"></bm-local-search>
            </baidu-map>
        </div>
    </template>
    <script>

    //地图组件---按需引入 import {BaiduMap, BmControl, BmView, BmAutoComplete, BmLocalSearch, BmMarker} from 'vue-baidu-map' export default { components: { BaiduMap, BmControl, BmView, BmAutoComplete, BmLocalSearch, BmMarker }, data: function () { return { showMapComponent: this.value, keyword: '', mapStyle: { '100%', height: this.mapHeight + 'px' }, center: {lng: 116.404, lat: 39.915}, zoom: 15 } }, watch: { value: function (currentValue) { this.showMapComponent = currentValue if (currentValue) { this.keyword = '' } } }, methods: { /*** * 地图点击事件。 */ getClickInfo (e) { this.center.lng = e.point.lng this.center.lat = e.point.lat }, syncCenterAndZoom (e) { const {lng, lat} = e.target.getCenter() this.center.lng = lng this.center.lat = lat this.zoom = e.target.getZoom() }, } } </script>
    <style scoped>
        .serachinput {
             300px;
            box-sizing: border-box;
            padding: 9px;
            border: 1px solid #dddee1;
            line-height: 20px;
            font-size: 16px;
            height: 38px;
            color: #333;
            position: relative;
            border-radius: 4px;
            -webkit-box-shadow: #666 0px 0px 10px;
            -moz-box-shadow: #666 0px 0px 10px;
            box-shadow: #666 0px 0px 10px;
        }
    </style>
  • 相关阅读:
    Laravel模型间关系设置分表方法详解
    11个PHP程序员最常犯的MySQL错误
    教你使用swoole监听redis数据
    使用 Docker 环境来开发 PHP,Laradock 系列 1
    tp5 workerman安装不上解决方法
    一种颗粒度很小的 Laravel 路由文件划分方式
    VT 调试环境搭建
    masm32基本配置与写出第一个汇编程序
    [debug] 解决pycharm中无法import自己建立的模块问题
    《Windows内核安全与驱动开发》 7.1&7.2&7.3 串口的过滤
  • 原文地址:https://www.cnblogs.com/tuspring/p/9924522.html
Copyright © 2011-2022 走看看