Git Product home page Git Product logo

Comments (7)

jacobtoye avatar jacobtoye commented on June 18, 2024

I thought there might have been a z-index modifier in L.Popup, but unfortunately there isn't :(

The reason why this is happening is because I add the labels to the same Leaflet container as the popups. We could add a new container that is positioned under the popup one. I'll need to think about it.

You could use Leaflet.iconlabel which provides similar functionality, but stores the label element at the same level as the marker icon.

from leaflet.label.

jacobtoye avatar jacobtoye commented on June 18, 2024

Static labels are now added to the marker pane and synced up with the z-index of the marker. This should mean they are always behind popups.

e60bd35

from leaflet.label.

Lukas-bw avatar Lukas-bw commented on June 18, 2024

wow, works perfectly, thank you! :)

from leaflet.label.

Lukas-bw avatar Lukas-bw commented on June 18, 2024

Hi jacobtoye,

unfortunately my website does not work anymore since the update I did just noticed it today.
I display a realtime layer on my map where markers move each 10 seconds, and of course I need to move the labels as well.
I am doing it like this right now:

                        Vehicle[i].hideLabel();
                        Vehicle[i].unbindLabel();
                        Vehicle[i].setLatLng(new L.LatLng(update[i][0],updatei][1]));
                        Vehicle[i].bindLabel(update[i][3], { noHide: true });
                        Vehicle[i].showLabel(); 

Since the update (maybe some older issue, I did not update since january) I am getting the following error:

Uncaught TypeError: Cannot convert null to object leaflet-src.js:403
L.Mixin.Events.removeEventListener leaflet-src.js:403
L.Marker.include.unbindLabel leaflet.label.js:9
$.ajax.success MapFunctions.js:980
fire jquery-1.8.2.js:974
self.fireWith jquery-1.8.2.js:1082
done jquery-1.8.2.js:7788
callback

Leaflet src at line 403 is delete events[objKey][contextId];

So unbindlabel is causing the problem I think

EDIT:
The version from January does not work as well, it tells me: this._label is null after the first bind/unbind

The only version that does work for me is from october 2012 !

So maybe the question is, how should I move a static label with the marker? Seems that my approach is not valid anymore.

from leaflet.label.

tomchadwin avatar tomchadwin commented on June 18, 2024

I still have labels overlapping popups. Has this issue reappeared?

from leaflet.label.

muziejus avatar muziejus commented on June 18, 2024

I, too, am having this problem, and this is with adding the pane: 'markerPane' option.

This is w/ version 0.2.2-dev.

from leaflet.label.

muziejus avatar muziejus commented on June 18, 2024

I solved the problem at least for myself.

this._pane=this._source instanceof L.Marker?t._panes.markerPane:t._panes.popupPane

This suggests that if the source is not on the markerPane (say it's on the overlayPane, like a polygon would be), then the label is placed on the popupPane.

So I just changed this line of code to:

this._pane=this._source instanceof L.Marker?t._panes.markerPane:t._panes.markerPane

It works for my specific use case, in that I only ever have circleMarkers. Despite the documentation, which calls for a pane: 'markerPane' option, I haven't been able to get that to work. It was persistently putting my labels in the popupPane, and I think this snippet of code shows why.

Again, this is 0.2.2-dev.

from leaflet.label.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.