仅限制 Mapbox 平移 north/south?

Constrain Mapbox panning north/south only?

有人知道如何仅使用 north/south 边界来限制 Mapbox 地图中的平移吗?我想做的是使用世界副本,以便用户可以连续从东向西平移,但限制南北平移,这样您就不能平移到地图图块之外(我觉得这很烦人)。我目前在初始化地图时使用了 maxbounds 以防止平移到两极上方和下方的白色瓷砖,但这对世界复制来说是行不通的。

您可以在 L.LatLngBounds 中使用 -Infinity west 和 Infinity east (thnx Ivan) 来设置 maxBounds 选项:(在片段,但也应该适用于 Mapbox.js)

var map = new L.Map('leaflet', {
    'center': [0, 0],
    'zoom': 2,
    'worldCopyJump': true,
    'layers': [
        new L.TileLayer('//{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
            'attribution': '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, &copy; <a href="http://cartodb.com/attributions">CartoDB</a>'
        }),
        new L.Marker([0,0])
    ],
    'maxBounds': [
        [-90, -Infinity],
        [90, Infinity]
    ]
});
body {
    margin: 0;
}

html, body, #leaflet {
    height: 100%;
}
<!DOCTYPE html>
<html>
  <head>
    <link type="text/css" rel="stylesheet" href="//cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
  </head>
  <body>
    <div id="leaflet"></div>
    <script type="application/javascript" src="//cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
  </body>
</html>