【问题标题】:Disable horizontal repeating of world map with mapbox使用 mapbox 禁用世界地图的水平重复
【发布时间】:2014-03-25 22:57:14
【问题描述】:

我对 JS 很陌生,所以也许我的问题很容易解决,尽管我已经花了很多时间。

我正在使用带有传单 api 的 Mapbox,并且我想在缩小时禁用水平世界地图的重复。我已经探索了 maxBounds 属性,但它并不令人满意,因为我想将地图隐藏在边界之外。基本上,我想得到这个结果http://jsfiddle.net/zF6bf/,但不是“画布”,而是存储在 mapbox.com 上的这张地图:cartogrph.hbem5mod

此外,我想禁用拖动和缩放处理程序,因此我正在寻找与以下兼容的解决方案:

// disable drag and zoom handlers
map.dragging.disable();
map.touchZoom.disable();
map.doubleClickZoom.disable();
map.scrollWheelZoom.disable();
// disable tap handler, if present.
if (map.tap) map.tap.disable();

谁能帮助我?我会非常感激的。

提前致谢, 乔纳斯

【问题讨论】:

    标签: javascript maps leaflet mapbox


    【解决方案1】:

    我发现现有答案对我不起作用。但是您可以使用RenderWorldCopies 属性来执行此操作。见Docs

    您可以使用构造函数的选项

     new mapboxgl.Map({
                renderWorldCopies: false,
                // your other options....
     })
    

    或者用方法:

    map.setRenderWorldCopies(true);
    

    【讨论】:

      【解决方案2】:

      查看文档:Disable World Wrapping

      <script>
      var map = L.mapbox.map('map','cartogrph.hbem5mod', {
          // these options apply to the tile layer in the map
          tileLayer: {
              // this map option disables world wrapping. by default, it is false.
              continuousWorld: false,
              // this option disables loading tiles outside of the world bounds.
              noWrap: true
          }
      }).setView([38, -102.0], 5);
      </script>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-06
        • 2013-12-28
        • 1970-01-01
        • 2014-11-21
        相关资源
        最近更新 更多