javascript - 使用 mapbox 禁用世界地图的水平重复

标签 javascript maps leaflet mapbox

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

我将 Mapbox 与 leaflet api 一起使用,我想在缩小时禁用水平世界地图的重复。我已经探索了 maxBounds 属性,但并不令人满意,因为我想将 map 隐藏在边界之外。基本上,我想要这个结果 http://jsfiddle.net/zF6bf/但不是“ Canvas ”,我想要这张 map ,存储在 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();

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

提前致谢, 乔纳斯

最佳答案

查看文档: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>

关于javascript - 使用 mapbox 禁用世界地图的水平重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21985064/

相关文章:

ios - 使用 Google Maps API for IOS 的区域边界坐标

javascript - Google map gpx 导出 - 在 JavaScript 中保存对话框

javascript - Google map 事件监听器在 Javascript 'for' 循环中无法正常工作

javascript - 我无法让 esri-leaflet 与 ReactJS 一起工作 --> 未定义的 basemapLayer

html - 传单 map 不会在浏览器中呈现

angular - 可以在来自第三方库的 DOM 元素中渲染 Angular 2 组件吗?

javascript - 在 angularjs 中使用 wijmo 事件日历

javascript - 当 Canvas 尺寸改变时需要帮助重新定位一个圆圈

javascript - Angular.js错误: Duplicates in a repeater are not allowed - Track by index doesn't work

javascript - 我不断收到 'Uncaught TypeError: Cannot read property ' value' of null' 响应,但不明白为什么