Prevent Unfolding Map from panning off screen

When I using unfolding maps, there is no limit on how far you can pan. When you pan too far, however, this happens:

I have tried restricting panning via the method setPanningRestriction(center, maxdistance), however this does not work well. For one, the docs say that maxdistance is kilometers, and that panning is restricted radially by maxdistance.

1.) Unfolding thinks that the earth is only 3000 kilometers in circumfereance.
2.) The restriction INCREASES as you zoom into the map. By the time you are zoomed to city level, you cannot pan at all.

Any simple solutions appreciated.

1 Like

Did you try contrain() with variable argument ?

Hi There!

What variable do you suggest I constrain? mouseX and mouseY don’t seem like good candidates.


I never use this library. What’s function allows you to zoom ?

Please share your working code reproducing the problem.

Panning restriction documented here:
If it does not work as advertised, file an issue with the library owner


1 Like

Well, zoom is not the issue. Panning is the issue… but that does give me an idea. Let me try something and get back to you. Thanks!

I have already done that. If you have a work-around please feel free to contribute to the thread.

I will post my code later when I have time to trim it down to something reasonably readable on this forum.

1 Like