简体   繁体   English

如何使用我自己的html / css自定义Mapzen搜索控件?

[英]How to customize Mapzen search control using my own html/css?

How can I customize an L.Mapzen.geocoder to take my own HTML/CSS styled search box that is positioned at the center (just like the one in Mapzen Demo)? 如何自定义L.Mapzen.geocoder以采用位于中心的我自己的HTML / CSS样式的搜索框(就像Mapzen演示中的那个一样)?

<div id="form-wrapper">
    <form class="form-horizontal">
      <div class="col-lg-offset-3 col-lg-6">
        <div class="input-group">
          <input type="text" class="form-control input-sm">
                  <span class="input-group-btn">
                    <button class="btn btn-default btn-sm" type="submit"><span class="glyphicon glyphicon-search"></span></button>
                  </span>
          </input>
        </div>
      </div>
    </form>
</div>

I wanted to let it stay at the center as the map adjusts to the location as its background. 我想让它停留在中心,因为地图会根据背景调整为该位置。

Its basic use is to let the users check if the location they chose is correct and after another button click their input will be redirected to another python django view. 它的基本用途是让用户检查他们选择的位置是否正确,并在单击另一个按钮后将其输入重定向到另一个python django视图。

Here is how the Mapzen demo was created. 这是Mapzen演示的创建方式。

  1. set the geocoder expanded option to true so that it is always expanded (otherwise, there will just be a search icon floating in the middle of the page) 将地址解析器expanded选项设置为true,以使其始终处于扩展状态(否则,页面中间只会浮动一个搜索图标)

  2. add this CSS 添加此CSS

     .leaflet-top { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; } 
  3. adjust .leaflet-pelias-control to your desired width and height in CSS 在CSS .leaflet-pelias-control调整为所需的宽度和高度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM