Disable horizontal repeating of world map with mapbox
Asked Answered
N

2

6

I'm quite new to JS, so maybe my problem will be easy to solve, though I already spent many hours on it.

I'm using Mapbox with the leaflet api, and I would like to disable the repeating of horizontal world maps when zooming out. I already explored the maxBounds properties, but it is not satisfying, as I want to hide the map outside the bounds. Basically, I would like to have this result http://jsfiddle.net/zF6bf/ but instead of "canvas", I would like to have this map, stored on mapbox.com : cartogrph.hbem5mod

Moreover, I would like to disable drag and zoom handlers, so I'm looking for a solution which would be compatible with the following:

// 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();

Can anyone help me? I would be really greatful.

Thanks in advance, Jonas

Nebulosity answered 24/2, 2014 at 10:29 Comment(0)
C
7

See the docs: 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>
Chericheria answered 14/5, 2014 at 0:49 Comment(0)
V
7

I found the existing answer didn't work for me. But you can use the RenderWorldCopies property to do this. See the Docs

You can use the Constructor's Option

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

Or with the method:

map.setRenderWorldCopies(true);
Vallie answered 16/11, 2020 at 15:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.