2

When you render a map if you zoom out far enough it will repeat the map infinite times.

The problem is that the coordinates will increase if you drag something outside the "original" map.

Example:

enter image description here

and if you drag to the left

enter image description here

The 'lat' seems to be fine, since it only duplicates horizontally, but 'lng' is way off.

Is there a way to correct the position?

L.vesion = "1.0.0-rc.3+27f05a2"

2
  • 1
    lng isn't "way off", it's just a world over. 360 + 52 = 412.
    – Midavalo
    Commented Apr 20, 2017 at 14:39
  • Midavalo is right. Try limiting your min zoom and using world wrap - that will keep the coordinates within 0-360 Commented Apr 20, 2017 at 16:15

1 Answer 1

1

A simple calculation with the maximum bounds of the globe's coordinates can do the trick.

Top left corner: (85, -180). Bottom right corner: (-85.05115, 180).

Just have to verify if it's inside the borders.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.