Leaflet: Markers Don't Repeat

Created on 7 Aug 2013  路  15Comments  路  Source: Leaflet/Leaflet

I need markers to repeat across as different world maps are shown as you pan.

I have created a jsfiddle at:
http://jsfiddle.net/deliriousrhino/u387Q/3/

If you look at New Zealand you will see my issue. There should be markers on either side of the country.

I tried worldCopyJump = true, however it throws an error "Set map center and zoom first."

Also I am no sure worldCopyJump is the functionality I am after since I need all the markers around the -180 and 180 longitude to be shown together.

Most helpful comment

3 years later: Is it nowadays possible to do what was out of scope (show two markers of the same node at lower zoom)?

All 15 comments

Hello,

you can workaround the "Set map center and zoom first" error by disabling map.dragging first and then enable it later.

In your fiddle for example put in line 2:

options.dragging = false;

Then add

map.dragging.enable();

in the line after

map.setView(lonLat, 1);

to enable dragging after setting the view.

But I'm not sure if that behaviour is what you want.

lg

fastrde

Thanks fastrde that does fix the world jump issues.
But yes it is not the effect I am after. I would like the markers to repeat so you can see all the markers that are around New Zealand at the one time

if you want to focus your map around the edge of the world, you can add 360 to the lon value of those you want 1 world over.
http://jsfiddle.net/u387Q/6/

Great thanks for that Danzel.

I guess this can be closed now. "True" marker repeat across world copies (so that there can be 2 markers for one place at the same time on lower zooms) is out of scope at the moment I think. There's also an attempt at doing this automatically here #1293, currently on hold because of performance concerns

3 years later: Is it nowadays possible to do what was out of scope (show two markers of the same node at lower zoom)?

+1

Subscribed here

Another year later. Is it possible?

@ooMICAHoo nope, no work has been done in this area, to my knowledge. IMO, this is a pretty niche use case and as mentioned above and in #1293, any suggested method to approach this has performance implications.

To resolve this, we would need someone who thinks this is a relevant feature to step up and actually do the work, it will not be resolved by itself. Having said that, if you want to take this on, please discuss the changes before actually making them, since it is likely we would turn down a pull request which affects performance significantly for normal use cases.

Thank you for responding! I understand. It's not a big deal for my project so I am fine without the capabilities.

@perliedman I'd like to volounteer, but I'm pretty newbish to JS (not to coding per se though) so I wonder if you can give some guidelines for performance testing so that I can check whether my code would result in a significant overhead.

And yes, very relevant feature to us, we're currently doing a lot of stub code to get around that.

+1

Another year later 馃ぃ

It's 2019. Thanks to @IvanSanchez there is a plugin.

If you don't want to have any plugins this could help as well:
https://stackoverflow.com/questions/33632608/markers-do-not-appear-on-continuous-world-in-leaflet

Was this page helpful?
0 / 5 - 0 ratings