Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Static labels do not play with leaflet.markercluster #35

Closed
bertbesser opened this issue Jul 15, 2013 · 10 comments
Closed

Static labels do not play with leaflet.markercluster #35

bertbesser opened this issue Jul 15, 2013 · 10 comments
Assignees

Comments

@bertbesser
Copy link

Hi,

first of all thanks for the plugin, in particular for static labels and the ability to have several labels display at the same time.

However, when using your plugin together with markercluster, static labels do not show up again when a marker is unclustered. Furthermore, once the zoom level changes, a static label of a marker, that was unclustered before and is still unclustered, disappears.

Best regards,
ugh-bough

@bertbesser
Copy link
Author

Ive put up a jsfiddle: http://jsfiddle.net/67njh/2/
I was wrong in one point: the static label works correct until the marker gets clustered, after unclustering the static label is gone and will never show up again.

@bertbesser
Copy link
Author

Unfortunately, listening when the clustering animation has ended and then calling showLabel() is not enough: if a cluster is outside of viewable area, then the label for the unclustered marker is not shown.

http://jsfiddle.net/67njh/3/

@jacobtoye
Copy link
Member

I think the issue is that Leaflet.markerclusterer removes markers from the map that are outside a bounds. My initial thought was to listen for layeradd events and if the layer is a marker with a static label -> show it.

However adding the code, didn't seem to work.

map.on('layeradd', function(e) {
    if (e.layer instanceof L.Marker && e.layer._labelNoHide) {
        e.layer.showLabel();
    }
});

I'll have a chat to @danzel tomorrow. He should be able to give me better insight into how Leaflet.markercluster works in this case.

@bertbesser
Copy link
Author

Hi. I solved for me by listening to moveend on the map and on animationend on the markerclustergroup and showing the label of every marker.

This however will not scale for many markers...

Best regards.

Jacob Toye notifications@github.com wrote:

I think the issue is that Leaflet.markerclusterer removes markers from
the map that are outside a bounds. My initial thought was to listen for
layeradd events and if the layer is a marker with a static label ->
show it.

However adding the code, didn't seem to work.

map.on('layeradd', function(e) {
   if (e.layer instanceof L.Marker && e.layer._labelNoHide) {
       e.layer.showLabel();
   }
});

I'll have a chat to @danzel tomorrow. He should be able to give me
better insight into how Leaflet.markercluster works in this case.


Reply to this email directly or view it on GitHub:
#35 (comment)

@danzel
Copy link
Member

danzel commented Jul 23, 2013

It would be nice if you could call show before the marker was on the map and never have to worry about it again.
I need this for our own app, so I'll take a look.

@danzel danzel reopened this Jul 23, 2013
@ghost ghost assigned danzel Jul 23, 2013
@pabloalcaraz
Copy link

Hi, there are a solution for this?

I need it for my mobile app, and I have approximately 200 markers, so I can't use the above method for efficiency.

Thanks!

@jacobtoye
Copy link
Member

Yeah I'll take a look today :)

@pabloalcaraz
Copy link

Hi, thank you for the commit :)

But I have just test it and isn't work on mobile browsers.

When I expand a cluster with markers with labels, the markers out of the screen doesn't display the label, although I drag the screen, only with zoomIn the label is displayed.

On desktop browsers works perfectly, but on iOs and Android no.

Thanks!

@gommo
Copy link

gommo commented Sep 6, 2015

I get this still too on iPad etc..

@Klapsa2503
Copy link

Klapsa2503 commented Jul 15, 2016

The issue also appears in JavaFX app where I am displaying a map. Labels are not rendered outside visible bounds. I managed to resolve issue by setting removeOutsideVisibleBounds: false.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants