【问题标题】:Remove right and bottom margin on infowindows删除 infowindows 上的右边距和下边距
【发布时间】:2014-02-27 20:30:45
【问题描述】:

我在玩 google InfoWindow。

而且几乎一切都很完美。我只是在窗户上遗漏了一些东西。

我总是有一个右下角的空白。

我不太介意底部的那个,但我想摆脱正确的那个。

知道怎么做吗?

编辑,这里是代码:

<div class="gm-style-iw" style="position: absolute; left: 12px; top: 9px; overflow: auto; width: 352px; height: 290px;">
  <div class="" style="overflow: auto;">
    <div class="infoBox">
      <div style="max-width: 352px; padding: 0px;">
        <div id="info-map-element"> 
          <div class="street"> 
            <img src="http://maps.googleapis.com/maps/api/streetview?size=360x190&amp;location=37.7831059,-122.4446528&amp;fov=90&amp;heading=235&amp;pitch=10&amp;sensor=false" alt=""> 
            <div class="shadow"></div>
            <div class="title"> Customer History<br> 123 Foo Av, San Francisco, CA 12345</div>       
          </div>
          <div class="wrap clearfix"> 
            <div class="item  clearfix">
              <small>2013-09-11</small>
              <p>This is the a test of customer history purchases.</p>
                <div class="row clearfix">
                  <div class="col-lg-5"> Cost Estimate <span>$11000</span></div>
                <div class="col-lg-7"> Purchase No. <span>123456789</span></div>
            </div> 
            <div class="row clearfix">
              <div class="col-lg-12"> Sell by <a href="">My Online seller dot com</a></div>
            </div>
          </div>
          <div class="row clearfix"></div>
        </div>
      </div>
    </div>
  </div>
</div>


#map_newsfeed .gm-style-iw {
    width: 352px!important;
    height: auto!important;
    left: 0!important;
    font-size: 15px!important;
    font-weight: normal!important;
    top: 0!important;
    overflow: hidden!important;
    border-radius: 3px;
}
#map_newsfeed .gm-style-iw > div {
    overflow: hidden!important;
}.gm-style .gm-style-iw, .gm-style .gm-style-iw a, .gm-style .gm-style-iw span, .gm-style .gm-style-iw label, .gm-style .gm-style-iw div {
    font-size: 13px;
    font-weight: normal;
}#info-map-element .row > div {
    font-size: inherit;
    font-weight: inherit;
}
#info-map-element .shadow {
    width: 100%;
    height: 100%;
    bottom: 0;
    -webkit-box-shadow: 0 -35px 75px rgba(0,0,0,0.95) inset;
    box-shadow: 0 -35px 75px rgba(0,0,0,0.95) inset;
    position: absolute;
    font-style: normal;
    font-weight: normal;
    z-index: 1;
}
#map .gm-style {
    font-family: inherit;
}#info-map-element .pagination {
    margin: 10px 0 0;
}
.infoBox > img {
    position: absolute;
    top: 0px;
    right: 25px;
    display: block;
    z-index: 3;
}
#info-map-element .pointer {
    width:23px;
    height:19px;
    top: 99%;
    left: 41%;
    position:absolute;
    display:block;
    background: transparent url('http://d3flf7kkefqaeh.cloudfront.net/_assets/3/pointer_down.png'); 
}#info-map-element .wrap {
    padding: 0;
}
#info-map-element .wrap .item:nth-child(even) {
    background: #ececec;
}
#info-map-element .wrap .item {
    padding: 10px;
}#legend strong {
    float: left;
    margin: 0 10px 0 0;
    display: block;
}

EDTI #2: 所以我可以用 Jquery 以我想要的方式改变 dom。这 3 行有效”

$(".gm-style-iw").next("div").css("right", '52px');
$(".gm-style-iw").prev("div").children().last().css("width", '351px');
$($(".gm-style-iw").prev("div").children()[1]).css("width", '351px');

但由于某种原因,只有第一行被执行。

【问题讨论】:

  • 您可以简单地覆盖infoWindowcss。使用dev tools of browsers(F12) 检查这些元素,花点时间回来。
  • 从信息框中粘贴您的 html。
  • 我认为右边距是清除“关闭按钮”。
  • 添加了信息窗口的CSS+html。在源代码中它说 CSS 的信息框,但它是一个信息窗口

标签: javascript html css google-maps infowindow


【解决方案1】:

填充是由应用于.gm-style-iw-d div 的滚动引起的,这会删除它,但要小心并确保所有内容都符合信息窗口的最大宽度和高度,否则它将被隐藏。

.gm-style-iw-d {
    overflow: hidden !important;
}

【讨论】:

  • 感谢这个简单的解决方案!还要添加这个以删除信息窗口填充: .gm-style .gm-style-iw-c { padding: 0; }
【解决方案2】:

对于那些仍在寻找解决方案的人。 Angular 8 帮助下面的代码删除了填充并隐藏了 agm-info-window 的关闭按钮。 基本上,.gm-style-iw-d 元素中的 overflow: scroll 会创建该空间。

/* hide close button in info-window */
::ng-deep button.gm-ui-hover-effect {
  visibility: hidden;
}

/* clear the paddings  */
::ng-deep .gm-style .gm-style-iw-c {
  padding: 0;
}

/* remove the white space */
::ng-deep .gm-style-iw .gm-style-iw-d {
  overflow: auto !important;
}

【讨论】:

    【解决方案3】:

    您需要先移除 infowindow 背景和阴影,然后应用您自己的 css。

    JS部分

    /*
     * The google.maps.event.addListener() event waits for
     * the creation of the infowindow HTML structure 'domready'
     * and before the opening of the infowindow defined styles
     * are applied.
     */
    google.maps.event.addListener(infowindow, 'domready', function() {
    
       // Reference to the DIV which receives the contents of the infowindow using jQuery
       var iwOuter = $('.gm-style-iw');
    
       /* The DIV we want to change is above the .gm-style-iw DIV.
        * So, we use jQuery and create a iwBackground variable,
        * and took advantage of the existing reference to .gm-style-iw for the previous DIV with .prev().
        */
       var iwBackground = iwOuter.prev();
    
       // Remove the background shadow DIV
       iwBackground.children(':nth-child(2)').css({'display' : 'none'});
    
       // Remove the white background DIV
       iwBackground.children(':nth-child(4)').css({'display' : 'none'});
    
    });
    

    CSS 部分(示例)

    .gm-style-iw {
       width: 350px !important;
       top: 0 !important;
       left: 0 !important;
       background-color: #fff;
       box-shadow: 0 1px 6px rgba(178, 178, 178, 0.6);
       border: 1px solid rgba(72, 181, 233, 0.6);
       border-radius: 2px 2px 0 0;
    }
    

    Source

    【讨论】:

      【解决方案4】:

      您应该停止尝试修复高度/宽度并将其设置为自动。
      尝试更改此行:

      <div class="gm-style-iw" style="position: absolute; left: 12px; top: 9px; overflow: auto; width: 352px; height: 290px;">
      

      对此:

      <div class="gm-style-iw" style="position: absolute; left: 12px; top: 9px; overflow: auto; width: auto; height: auto;">
      


      在 Css 更改中:

      #map_newsfeed .gm-style-iw {
        width: 352px!important;
        height: auto!important;
        left: 0!important;
        font-size: 15px!important;
        font-weight: normal!important;
        top: 0!important;
        overflow: hidden!important;
        border-radius: 3px;
      }
      

      收件人:

      #map_newsfeed .gm-style-iw {
        width: auto!important;
        height: auto!important;
        left: 0!important;
        font-size: 15px!important;
        font-weight: normal!important;
        top: 0!important;
        overflow: hidden!important;
        border-radius: 3px;
      }
      


      它应该可以解决您的问题,如果没有,请显示完整代码(html/css)。

      【讨论】:

      • 嗨@bl0b 你得到任何答案了吗?我正在寻找同样的东西。谢谢
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-11
      • 2017-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-29
      • 1970-01-01
      相关资源
      最近更新 更多