1

I hope someone can lend some insight here. My customer is complaining about what he calls the "multiverse" issue in Leaflet.

I apologize if I'm not using the right words to describe the problem.

As everyone knows, in leaflet you can scroll right/left on the map giving the appearance that you are "scrolling around the world"...however, each world map to the left and right are actually independently mapped using a continuum of longitudes...

For example, this picture shows (roughly) three earths: multiverse

The left one from -540 to -180, middle from -180 to 180, right from 180 to 540.

And note the pin on the middle earth doesn't show on the left or right earths.

Is there any reasonable way to eliminate the "multiverse" feature (shy of replicating all of the elements N number of times)?

4
  • 2
    You can use tile layer noWrap: true option.
    – TomazicM
    Sep 27 at 20:26
  • I was still hoping to be able to pan left and right, so this isn't quite it. Thanks for commenting
    – David Hope
    Sep 27 at 20:57
  • If you have only markers, you could use gitlab.com/IvanSanchez/Leaflet.RepeatedMarkers
    – TomazicM
    Sep 28 at 8:26
  • unfortunately I've got lines and polygons also...the worldCopyJump answer below resolved my issue sufficiently
    – David Hope
    Sep 29 at 12:15

1 Answer 1

1

There are some options mentioned in the options for the Map object.

  • Set maxBounds with a longitude range of -180, 180
    • maxBoundsViscosity can be used to control the behaviour of panning at the edges
  • Set worldCopyJump to True
3
  • the bounds don't really help, because my customer has a scenario that may cover the pacific ocean, so cutting it off. in the middle doesn't resolve the issue. Looking at worldCopyJump, but it seems to have the same sort of issue.
    – David Hope
    Sep 27 at 21:03
  • 2
    Anything in the Pacific unfortunately comes up against antimeridian issues, and there is no good solution in Leaflet, shy of doing things with non-default coordinate reference systems and producing your own basemap tiles to match that projection. openlayers tends to do some of this stuff better, but tends to be a slightly more difficult API. Sep 27 at 21:25
  • I accepting worldCopyJump as the correct answer here. I needed to supplement by creating 2 additional markers, one at location-180 longitude and one at location+180 longitude. Thanks!
    – David Hope
    Sep 28 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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