• <tfoot id='ZRxst'></tfoot>
    <i id='ZRxst'><tr id='ZRxst'><dt id='ZRxst'><q id='ZRxst'><span id='ZRxst'><b id='ZRxst'><form id='ZRxst'><ins id='ZRxst'></ins><ul id='ZRxst'></ul><sub id='ZRxst'></sub></form><legend id='ZRxst'></legend><bdo id='ZRxst'><pre id='ZRxst'><center id='ZRxst'></center></pre></bdo></b><th id='ZRxst'></th></span></q></dt></tr></i><div id='ZRxst'><tfoot id='ZRxst'></tfoot><dl id='ZRxst'><fieldset id='ZRxst'></fieldset></dl></div>

    1. <small id='ZRxst'></small><noframes id='ZRxst'>

      • <bdo id='ZRxst'></bdo><ul id='ZRxst'></ul>
      <legend id='ZRxst'><style id='ZRxst'><dir id='ZRxst'><q id='ZRxst'></q></dir></style></legend>

      1. 自定义leaflet.js中的放大/缩小按钮

        时间:2023-08-08

            <legend id='kCTZ6'><style id='kCTZ6'><dir id='kCTZ6'><q id='kCTZ6'></q></dir></style></legend>
            • <small id='kCTZ6'></small><noframes id='kCTZ6'>

              • <bdo id='kCTZ6'></bdo><ul id='kCTZ6'></ul>
                  <tbody id='kCTZ6'></tbody>
                <tfoot id='kCTZ6'></tfoot>
                <i id='kCTZ6'><tr id='kCTZ6'><dt id='kCTZ6'><q id='kCTZ6'><span id='kCTZ6'><b id='kCTZ6'><form id='kCTZ6'><ins id='kCTZ6'></ins><ul id='kCTZ6'></ul><sub id='kCTZ6'></sub></form><legend id='kCTZ6'></legend><bdo id='kCTZ6'><pre id='kCTZ6'><center id='kCTZ6'></center></pre></bdo></b><th id='kCTZ6'></th></span></q></dt></tr></i><div id='kCTZ6'><tfoot id='kCTZ6'></tfoot><dl id='kCTZ6'><fieldset id='kCTZ6'></fieldset></dl></div>
                1. 本文介绍了自定义leaflet.js中的放大/缩小按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试自定义缩放控制 (+/-),因此它应该像 Google 地图一样出现在右侧 (https:///www.google.com/maps/)

                  I am trying to customize zoom control (+/-), so it should appear in the right side like Google maps (https://www.google.com/maps/)

                  我尝试添加 float:right; 但没有成功.

                  I tried to add float:right; but it didn't work.

                  来自 CSS 文件:

                  /* zoom control */
                  
                  .leaflet-control-zoom-in,
                  .leaflet-control-zoom-out {
                    font: bold 18px 'Lucida Console', Monaco, monospace;
                    text-indent: 1px;
                    }
                  .leaflet-control-zoom-out {
                    font-size: 20px;
                    }
                  
                  .leaflet-touch .leaflet-control-zoom-in {
                    font-size: 22px;
                    }
                  .leaflet-touch .leaflet-control-zoom-out {
                    font-size: 24px;
                    }
                  

                  http://jsfiddle.net/hsy7v/1/

                  推荐答案

                  你的放大/缩小控件被绝对定位的元素包裹着 left:0 (由于 .leaflet-left 类),所以 float:left 无济于事,您可以通过 right:0 覆盖 left:0 或更改 来将其右对齐>.leaflet-left 类到 .leaflet-right

                  Your zoom in/out controls are wrapped with absolutely positioned element with left:0 (due to .leaflet-left class), so float:left wouldn't help, you could align it to right by overriding left:0 by right:0, or changing .leaflet-left class to .leaflet-right

                  但更正确的方法是使用提供的 api.

                  But more correct way would be to use provided api.

                  //disable zoomControl when initializing map (which is topleft by default)
                  var map = L.map("map", {
                      zoomControl: false
                      //... other options
                  });
                  
                  //add zoom control with your options
                  L.control.zoom({
                       position:'topright'
                  }).addTo(map);
                  

                  查看更新的 fiddle

                  您使用的库的 api 参考可以在 这里

                  api reference for the library you use can be found here

                  这篇关于自定义leaflet.js中的放大/缩小按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在容器 div 内定位地图框/传单地图 下一篇:将传单地图导出到 geojson

                  相关文章

                  最新文章

                2. <i id='TNIXx'><tr id='TNIXx'><dt id='TNIXx'><q id='TNIXx'><span id='TNIXx'><b id='TNIXx'><form id='TNIXx'><ins id='TNIXx'></ins><ul id='TNIXx'></ul><sub id='TNIXx'></sub></form><legend id='TNIXx'></legend><bdo id='TNIXx'><pre id='TNIXx'><center id='TNIXx'></center></pre></bdo></b><th id='TNIXx'></th></span></q></dt></tr></i><div id='TNIXx'><tfoot id='TNIXx'></tfoot><dl id='TNIXx'><fieldset id='TNIXx'></fieldset></dl></div>

                    <small id='TNIXx'></small><noframes id='TNIXx'>

                      • <bdo id='TNIXx'></bdo><ul id='TNIXx'></ul>
                      <legend id='TNIXx'><style id='TNIXx'><dir id='TNIXx'><q id='TNIXx'></q></dir></style></legend>
                    1. <tfoot id='TNIXx'></tfoot>