Disable horizontal world map repeat

4,045 views
Skip to first unread message

Jonas Lismont

unread,
Feb 23, 2014, 9:12:00 AM2/23/14
to leafl...@googlegroups.com
Hello,

This is my first post on the forum, and I'm quite new to js, so maybe my problem will be easy to solve, though I already spent many hours on it.

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

aston...@gmail.com

unread,
Mar 2, 2014, 9:58:22 AM3/2/14
to leafl...@googlegroups.com
The example at http://jsfiddle.net/zF6bf/ DOES hide the map outside the bounds on my machine. To change the map you need to change the L.TileLayer URL and point it to your map on Mapbox.com...

Jonas Lismont

unread,
Mar 2, 2014, 2:03:57 PM3/2/14
to leafl...@googlegroups.com
This worked, thank you very much! 

For other begginners like me who have the same problem: note that the L.TileLayer URL needs a special format (see https://www.mapbox.com/mapbox.js/api/v1.6.1/l-tilelayer/)

aston...@gmail.com

unread,
Mar 3, 2014, 4:21:59 AM3/3/14
to leafl...@googlegroups.com
Thanks for referencing MapBox's "special needs"...
Reply all
Reply to author
Forward
0 new messages