最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable horizontal repeating of world map with mapbox - Stack Overflow

programmeradmin4浏览0评论

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 / but instead of "canvas", I would like to have this map, stored on mapbox : cartogrph.hbem5mod

Moreover, I would like to disable drag and zoom handlers, so I'm looking for a solution which would be patible 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

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/zF6bf/ but instead of "canvas", I would like to have this map, stored on mapbox. : cartogrph.hbem5mod

Moreover, I would like to disable drag and zoom handlers, so I'm looking for a solution which would be patible 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

Share Improve this question asked Feb 24, 2014 at 10:29 JonasJonas 731 gold badge1 silver badge8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 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>

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);
发布评论

评论列表(0)

  1. 暂无评论