daboers
2021-09-02 10:37
采纳率: 83.3%
浏览 24
已结题

如何响应式栅格,使屏幕过小时地图在同一行 ,小屏幕就分开各占一行

示例图

img

img

@section appStyle {
<style>
  .main-content {
    @*background-color:black;*@
    /*background: url(../img/background/bg_main_old.jpg) no-repeat center;*/
    background-size: cover;
    padding-top: 40px;
    padding-bottom: 16px;
  }

  .nav-tabs {
    border: none !important;
  }

  #surrounding {
    height: 400px
  }

  @*.search-container.body.item.description{flex:0050px;color:gray;}*@
</style>
<style>
  .bm-view {
    width: 100%;
    @*height:500px!important;*@
  }

  #searchCtrl {
    width: 38%;
  }

  .search-container {
    background-color: white;
    /*height: 80%;
        width: 30%;*/
  }

  .search-container .body {
    overflow: auto;
    height: 20.625rem;
  }

  .search-container .body .item {
    cursor: pointer;
    padding: 3px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    font-family: PingFangSC-Medium, PingFang SC;
  }

  .search-container .body .item:hover {
    color: #f16b2a;
    background-color: #ffe3d5;
  }

  .search-container .body .item .header {
    flex: 0 0 16px;
  }

  .search-container .body .item .content {
    flex: 1;
  }

  .search-container .body .item .description {
    flex: 0 0 50px;
    color: gray;
  }


  #content {
    height: 100%;
    position: relative;

  }

  #mapContainerForSurrounding {
    height: 25rem !important;
    position: relative;
    width: 100% !important;
    top: 0;
    left: 0px;

  }

  #address {
    height: 100%;
    background-color: #F8F8F8;
    width: 25%;
    position: relative;
    top: -400px;
    left: 0;
    color: #FF902B;
    overflow-y: scroll;
    scroll-behavior: smooth;
    min-width: 190px;
  }



  .col-xl-12 {
    margin-bottom: 10px;
  }

  #wuhan {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;
  }

  .addressName {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;
  }

  .addressLocation {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTel {
    font-size: 13px;
    line-height: 18px;
    color: black;
  }

  #ellowCrane {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;
  }

  .addressNametwo {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;
  }

  .addressLocationtwo {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTeltwo {
    font-size: 13px;
    line-height: 16px;
    color: black;
  }

  #wuhantwo {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;
    box-sizing: border-box;
  }

  .addressNamethree {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;

  }

  .addressLocationthree {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTelthree {
    font-size: 13px;
    line-height: 16px;
    color: black;
  }


  #wuhanthree {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;

  }

  .addressNamefore {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;
  }

  .addressLocationfore {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTelfore {
    font-size: 13px;
    line-height: 16px;
    color: black;
  }


  #wuhanfore {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;
  }

  .addressNamefive {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;
  }

  .addressLocationfive {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTelfive {
    font-size: 13px;
    line-height: 16px;
    color: black;
  }

  #wuhanfive {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;
  }

  .addressNamesix {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;
  }

  .addressLocationsix {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTelsix {
    font-size: 13px;
    line-height: 16px;
    color: black;
  }

  #wuhansix {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;
  }

  .addressNameseven {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;
  }

  .addressLocationseven {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTelseven {
    font-size: 13px;
    line-height: 16px;
    color: black;
  }


  #wuhanseven {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;
  }

  .addressNameeight {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;
  }

  .addressLocationeight {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTeleight {
    font-size: 13px;
    line-height: 16px;
    color: black;
  }

  #wuhaneight {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;
  }

  .addressNamenine {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;
  }

  .addressLocationnine {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTelnine {
    font-size: 13px;
    line-height: 16px;
    color: black;
  }

  #wuhannine {
    height: 33%;
    padding: 0 5px;
    font-size: 16px;
    margin-bottom: 3px;
    color: black;
  }

  .addressNameten {
    padding-top: 20px;
    font-weight: bold;
    box-sizing: border-box;
  }

  .addressLocationten {
    font-size: 13px;
    line-height: 16px;
    color: black;
    line-height: 25px;
  }

  .addresTelten {
    font-size: 13px;
    line-height: 16px;
    color: black;
  }

  .query {
    color: black;
    font-size: 38px;
    font-weight: bold;
    text-align: center;
  }

  form {
  @*   width: 60%; *@
    height: 3.75rem;
    margin: 0 auto;
    margin-bottom: 50px;
  }

  input {
    width: 100%;
    height: 100%;
    border-radius: 2.5em;
    border: none;
    padding: 0;
    outline: none;
    background-color: #F8F8F8;
    font-size: 13px;
    color: black;
    text-indent: 5em;

  }

  form img {
    width: 2.125rem;
    height: 2.125rem;
    position: relative;
    top: 48px;
    left: 23px
  }
</style>
}
<div class="main-content" id="app">
  <div class="col-lg-12 col-xl-12 col-12">
    <div class="row">
      <div class="col-lg-12 col-xl-12 col-12">
        <div class="form-group">
          <div class="">
            <div class="card-body">
              <div class="col-lg-12 col-xl-12 col-12 query">
                门店查询
              </div>

              <form class="col-lg-8 col-xl-8 col-12">
                <img src="~/img/search.png" alt="">
                <input type="text" placeholder="输入地址查找门店">
              </form>


              <div class="col-lg-12 col-xl-12 col-12">

                @* <partial name="SurroundingService"1111 /> *@

                <div id="surrounding" v-clock>
                  <div id="content">
                    <div id="mapContainerForSurrounding" class="bm-view"></div>
                    <div id="address">
                      <div id="wuhan">
                        <div class="addressName">TONI&GUY 东方广场店</div>
                        <div class="addressLocation">北京市东城区东长安街1号东方广场汇贤豪庭一层</div>
                        <div class="addresTel">Tel&nbsp;010-85182647</div>
                      </div>
                      <div id="ellowCrane">
                        <div class="addressNametwo">TONI&GUY 太古里店 </div>
                        <div class="addressLocationtwo">北京市朝阳区三里屯路11号院太古里北区N2号楼3层38单元</div>
                        <div class="addresTeltwo">Tel&nbsp;010-64167728</div>
                      </div>
                      <div id="wuhantwo">
                        <div class="addressNamethree">TONI&GUY 西红门荟聚店 </div>
                        <div class="addressLocationthree">北京市大兴区新宁街15号北京荟聚中心2-01-58-SU-A</div>
                        <div class="addresTelthree">Tel&nbsp;010-60293010</div>
                      </div>
                      <div id="wuhanthree">
                        <div class="addressNamefore">TONI&GUY 金融街店</div>
                        <div class="addressLocationfore">北京市西城区金城坊街2号金融街购物中心4层L404</div>
                        <div class="addresTelfore">Tel&nbsp;010-66220316</div>
                      </div>
                      <div id="wuhanfore">
                        <div class="addressNamefive">TONI&GUY 合生汇店</div>
                        <div class="addressLocationfive">北京市朝阳区西大望路21号(合生汇购物中心)L4层16号房屋</div>
                        <div class="addresTelfive">Tel&nbsp;010-67717520</div>
                      </div>
                      <div id="wuhanfive">
                        <div class="addressNamesix">TONI&GUY 颐堤港店</div>
                        <div class="addressLocationsix">北京市朝阳区酒仙桥路18号颐堤港LG-65</div>
                        <div class="addresTelsix">Tel&nbsp;010-84260688</div>
                      </div>
                  
                    </div>
                  </div>
                  <div id="searchCtrl" v-show="!config.isLoading">
                    <div class="panel panel-default">
                      <div class="panel-body">
                        <div class="search-container">
                          <ul class="nav nav-tabs" id="info">

                          </ul>
                          <div class="tab-pane fade in">

                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <div id="mapContainer" class="col-lg-8 col-xl-8 col-12 order-lg-8 order-xl-8">

              </div>
              <div class="store-list col-lg-4 col-xl-4 col-12">

              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
  $(function () {
    $('#courses').owlCarousel({
      margin: 10,
      loop: true,
      autoplay: {
        autoplay: true,
        autoplayTimeout: 5000,
        autoplayHoverPause: true,
        autoplaySpeed: 10
      },
      lazyLoad: true,
      responsiveClass: true,
      responsive: {
        0: {
          items: 1,
          nav: false,
          loop: true
        }
      }
    });
  });
  function initBMap() {
    return new Promise(function (resolve, reject) {
      window.onBMapCallback = function () {
        resolve(BMap)
      }
      var script = document.createElement('script')
      script.type = 'text/javascript'
      script.src = `https://api.map.baidu.com/api?v=3.0&ak=TyRPRXdH3tDd3VAVYObG2E9BpKlGMwYQ&callback=onBMapCallback&s=1`
      script.onerror = reject
      document.head.appendChild(script)
    })
  }
  @* const filterType = [     { id: 1, name: '商业', kw: ['银行', '便利店', '超市'], key: '0', tab: '商业' },     { id: 2, name: '交通', kw: ['地铁站', '公交', '火车站', '机场', '长途车站'], key: '1', tab: '交通' },     { id: 3, name: '教育', kw: ['幼儿园', '小学', '中学', '大学'], key: '2', tab: '教育' },     { id: 4, name: '医疗', kw: ['医院', '社康中心'], key: '3', tab: '医疗' },     ] *@
  const app = new Vue({
    el: '#app',
    data: {
      selected: 0,
      config: { isLoading: false },
      lng: 114.569,@* lng: 114.569  lat: 30.25698 *@
      lat: 30.25698, @* 武汉站 lng: 114.431263,lat: 30.61293 *@
      @* 黄鹤楼lng: 114.309172,lat: 30.549579 *@
      content: '',
    radius: 3000,
    config: {
    isLoading: true,
    isSearching: {
      "0": true,
      "1": true,
      "2": true,
      "3": true,
    }
  },
    filter: {
    keyword: ''
  },
    @* filterType: filterType, *@
    type: '0',
    point: {},
    zoom: 14,
    map: undefined,
    searchModel: [],
    searchResult: [],
    },
  filters: {
    short(value, length = 10) {
      if (!value) {
        return ''
      }
      if (value.length >= length) {
        return value.substring(0, length) + '...'
      }
      return value
    }
  },

  created() {
    this.init()
  },
  computed: {
    @* searchBy() {       return this.filterType.find(x => x.key === this.type).kw       }, *@
      dataSource() {
      return this.searchResult.filter(x => x.type === this.type)
    },
    filterResult() {
      return this.dataSource.filter(x => x.title.indexOf(this.filter.keyword) != -1)
    },
    totalCount() {
      return this.config.isSearching[this.type] ? '加载中...' : `共有${this.dataSource.length}条结果`
    }
  },
  methods: {
    show(m) {
      this.selected = m;
      //var items = $('.course-list').children('[data-cid]');
      //for (var i = 0; i < items.length; i++) {
      //    if (items[i].dataset.cid != m) {
      //        $(items[i]).addClass("hidden").addClass("animate");
      //    }
      //}
    },
    showAll() {
      this.selected = 0;
      //var items = $('.course-list').children();
      //for (var i = 0; i < items.length; i++) {
      //    $(items[i]).removeClass("hidden").removeClass("animate");
      //}
    },
    init() {
      const _self = this
      if (this.map === undefined) {
        this.config.isLoading = true
        initBMap().then(res => {
          _self.config.isLoading = false
          _self.map = new BMap.Map('mapContainerForSurrounding')
          _self.point = new BMap.Point(this.lng, this.lat)
          _self.map.centerAndZoom(_self.point, _self.zoom)
          _self.map.panBy(-100, 0)
          @*范围大圆圈代码  const circle = new BMap.Circle(_self.point, _self.radius, { strokeWeight: 1, fillOpacity: 0.3, strokeOpacity: 0.3, enableMassClear: false });
              _self.map.addOverlay(circle); *@
            _self.map.addOverlay(new BMap.Marker(_self.point, { enableMassClear: false }))
          _self.content && _self.initContent()
          _self.map.addControl(new BMap.ScaleControl())
          _self.map.addControl(new BMap.NavigationControl())
          _self.loadControl()
          _self.search(_self.type)
        }).catch(e => {
          console.log(e)
        })
      }
    },
    search(type) {
      const _self = this
      if (this.searchModel[type] === undefined) {
        this.searchModel[type] = new BMap.LocalSearch(this.map, {
          onSearchComplete: function (results) {
            if (_self.searchModel[type].getStatus() == BMAP_STATUS_SUCCESS) {
              let index = 1
              for (var i = 0; i < results.length; i++) {
                for (let m = 0; m < results[i].getCurrentNumPois(); m++) {
                  const ele = results[i].getPoi(m);
                  const distance = _self.calculateForDistance(_self.point.lat, _self.point.lng, ele.point.lat, ele.point.lng)
                  if (distance <= _self.radius) {
                    const data = { ...ele, distance: distance, index: index, type: type }
                    _self.searchResult.push(data)
                    index++
                  }
                }
              }
            }
            _self.config.isSearching[type] = false
            _self.loadMarks()
            _self.$forceUpdate()
          }
        });

        this.config.isSearching[type] = true
        @*  this.searchModel[type].searchNearby(this.searchBy, this.point, this.radius); *@
      } else {
        this.loadMarks()
      }
    },
    initContent() {
      const opts = {
        position: this.point, // 指定文本标注所在的地理位置
        offset: new BMap.Size(-30, -30), // 设置文本偏移量
        enableMassClear: false
      };
      // 创建文本标注对象
      const label = new BMap.Label(this.content, opts);
      // 自定义文本标注样式
      label.setStyle({
        padding: '0px 5px',
        borderColor: '#ccc',
        fontSize: '14px',
        height: '30px',
        lineHeight: '30px',
        fontFamily: '微软雅黑',
        opacity: 0.9,
        background: '#2776f9',
        color: '#fff'
      });
      this.map.addOverlay(label);
    },
    loadMarks() {
      //   this.map.clearOverlays()
      // 创建标注对象并添加到地图
      const _self = this
      for (var i = 0; i < _self.dataSource.length; i++) {
        const data = _self.dataSource[i]
        const point = data.point
        const marker = new BMap.Marker(point)
        const label = new BMap.Label(data.index, {
          offset: new BMap.Size(data.index > 9 ? 0 : 5, 4)
        })
        label.setStyle({
          //  background: 'none',
          //  color: '#fff',
          //  border: 'none'
        })
        marker.setLabel(label)
        this.map.addOverlay(marker)
        //给标注点添加点击事件。使用立即执行函数和闭包
        marker.addEventListener("click", function (e) {
          _self.openInfoWin(data)
        });

      }
    },
    loadControl() {
      const _self = this
      //定义一个控件类
      function SearchControl() {
        this.defaultAnchor = BMAP_ANCHOR_TOP_RIGHT;
        this.defaultOffset = new BMap.Size(20, 20)
      }
      //通过JavaScript的prototype属性继承于BMap.Control
      SearchControl.prototype = new BMap.Control();

      //自定义控件必须实现自己的initialize方法,并且将控件的DOM元素返回
      //在本方法中创建个div元素作为控件的容器,并将其添加到地图容器中
      SearchControl.prototype.initialize = function (map) {
        //创建一个dom元素
        var div = document.getElementById("searchCtrl")
        // 添加DOM元素到地图中
        _self.map.getContainer().appendChild(div);
        // 将DOM元素返回
        return div;
      }
      //添加到地图中
      _self.map.addControl(new SearchControl());
    },
    openInfoWin(x) {
      const str = (x.title || "").length >= 12 ? `${x.title.substring(0, 12)}...` : x.title
      const titleHtml = `<div style="font-weight:bold;color:#CE5521;font-size:14px">${str}</div>`
      const opts = {
        width: 200,
        height: 50,
        title: titleHtml
      }
      const infoWindow = new BMap.InfoWindow('地址:' + (x.address || (x.title || "")), opts);
      this.map.openInfoWindow(infoWindow, x.point)
    },
    calculateForDistance(lat1, lon1, lat2, lon2) {
      const DEF_PI = 3.14159265359; // PI
      const DEF_2PI = 6.28318530712; // 2*PI
      const DEF_PI180 = 0.01745329252; // PI/180.0
      const DEF_R = 6370693.5; // radius of earth
      // 角度转换为弧度
      const ew1 = lon1 * DEF_PI180;
      const ns1 = lat1 * DEF_PI180;
      const ew2 = lon2 * DEF_PI180;
      const ns2 = lat2 * DEF_PI180;
      // 经度差
      let dew = ew1 - ew2;
      // 若跨东经和西经180 度,进行调整
      if (dew > DEF_PI)
        dew = DEF_2PI - dew;
      else if (dew < -DEF_PI)
        dew = DEF_2PI + dew;
      const dx = DEF_R * Math.cos(ns1) * dew; // 东西方向长度(在纬度圈上的投影长度)
      const dy = DEF_R * (ns1 - ns2); // 南北方向长度(在经度圈上的投影长度)
      // 勾股定理求斜边长
      let distance = Math.sqrt(dx * dx + dy * dy).toFixed(0);
      return ++distance;
    },
    showTab(x) {
      this.type = x.key;
      this.search(this.type)
    }
  }
  });


  let btn = document.getElementById("wuhan")
  let div = document.getElementById('ellowCrane')
  let addressName = document.querySelector(".addressName")
  let addressLocation = document.querySelector(".addressLocation")
  let addresTel = document.querySelector(".addresTel")

  let ellowCraneaddressName = document.querySelector('.addressNametwo')
  let ellowCraneaddLocation = document.querySelector('.addressLocationtwo')
  let ellowCraneaddaddresTel = document.querySelector('.addresTeltwo')
  let ellowCrane = document.getElementById("ellowCrane")

  let wuhantwo = document.getElementById("wuhantwo")
  let addressNamethree = document.querySelector('.addressNamethree')
  let addressLocationthree = document.querySelector(".addressLocationthree")
  let addresTelthree = document.querySelector(".addresTelthree")



  btn.addEventListener("click", function () {
    // surrounding.lat = 114.431263 surrounding.lng = 30.61293武汉站金纬度
    //114.569 30.25698  这里的applat和lng代表挂载的上述app的经纬度 116.422325,39.916088
    app.lat = 39.916088
    app.lng = 116.422325
    //  重新定位 ,先定位再重新绘制 app.lng, app.lat GL
    app.point = new BMap.Point(app.lng, app.lat)
    // 重新绘制地图
    app.map.centerAndZoom(app.point, app.zoom)
    // var map = new BMap.Map('app'); 这是把新的经纬度的坐标给标记点
    app.map.centerAndZoom(new BMap.Point(116.422325, 39.916088), 15);
    app.map.enableScrollWheelZoom(true);
    // 创建点标记
    var marker1 = new BMap.Marker(new BMap.Point(app.lng, app.lat));
    //在地图上添加点标记
    app.map.addOverlay(marker1)
  })
  btn.addEventListener("mouseover", function () {
    addressName.style.color = "white"
    btn.style.backgroundColor = '#FF902B'
    addressLocation.style.color = 'white'
    addresTel.style.color = "white"
    btn.addEventListener("mouseout", function () {
      addressName.style.color = ""
      btn.style.backgroundColor = ''
      addressLocation.style.color = ''///
      addresTel.style.color = ""
    })
  })
  div.addEventListener('click', function () {
    app.lat = 39.943977
    app.lng = 116.461649
    app.point = new BMap.Point(app.lng, app.lat)
    console.log(app.point)
    app.map.centerAndZoom(app.point, app.zoom)
    app.map.centerAndZoom(new BMap.Point(116.461649, 39.943977), 15);
    app.map.enableScrollWheelZoom(true);
    // 创建点标记
    var marker1 = new BMap.Marker(new BMap.Point(app.lng, app.lat));
    //在地图上添加点标记
    app.map.addOverlay(marker1);
  })
  div.addEventListener("mouseover", function () {
    ellowCraneaddressName.style.color = "white"
    div.style.backgroundColor = '#FF902B'
    ellowCraneaddLocation.style.color = 'white'
    ellowCraneaddaddresTel.style.color = "white"
    div.addEventListener("mouseout", function () {
      ellowCraneaddressName.style.color = ""
      div.style.backgroundColor = ''///
      ellowCraneaddLocation.style.color = ''
      ellowCraneaddaddresTel.style.color = ""
    })
  })




  
</script>


img
如何没缩小到一定距离之前,地址在左边,地图在右边,缩小到一定距离后,地址在下面,地图在上面了

有问题的图片
img

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题