Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FeatureGroup do not support tooltip with permanent: true (as advertised) #6938

Closed
5 tasks done
elmatou opened this issue Dec 12, 2019 · 3 comments
Closed
5 tasks done

Comments

@elmatou
Copy link

elmatou commented Dec 12, 2019

  • I've looked at the documentation to make sure the behavior is documented and expected
  • I'm sure this is a Leaflet code issue, not an issue with my own code nor with the framework I'm using (Cordova, Ionic, Angular, React…)
  • I've searched through the issues to make sure it's not yet reported

Steps to reproduce
Add a featureGroup with bindToolip to the map
Add a marker to the featureGroup

Expected behavior
every Marker should own (or share in this case) a tooltip which is permanently shown.
as documented "bindPopup binds a popup to all of the layers at once (likewise with bindTooltip)"

Current behavior
no Marker is shown
no Tooltip is shown
in console I get "Error: Unable to get source layer LatLng."

Environment

  • Leaflet version:
  • Browser (with version):
  • OS/Platform (with version):

Additional context

when removing permanent: true is removed everything works fine.

Minimal example reproducing the issue

https://next.plnkr.co/edit/S2W7zcKTkVIrFLur

  • this example is as simple as possible
  • this example does not rely on any third party code
@johnd0e
Copy link
Collaborator

johnd0e commented Apr 4, 2021

every Marker should own (or share in this case) a tooltip which is permanently shown.

I do not think so. The tooltip should be single.

as documented "bindPopup binds a popup to all of the layers at once (likewise with bindTooltip)"

Documentation is not precise here, just not best wording.

@johnd0e
Copy link
Collaborator

johnd0e commented Apr 4, 2021

in console I get "Error: Unable to get source layer LatLng."

That is because you are trying to open tooltip for empty FeatureGroup.
Addressed in #7540.

@johnd0e
Copy link
Collaborator

johnd0e commented Apr 4, 2021

So here is correct sample:

var markerGroup = new L.FeatureGroup([new L.Marker(map.getCenter())])
  .bindTooltip('balbla Tooltip', {permanent:true})
  .addTo(map);
map
  .on('click', function(e) {
    var marker = new L.Marker(e.latlng)
      .addTo(markerGroup);
  });

This keeps single tooltip and that is intended behavior.

@johnd0e johnd0e closed this as completed Apr 4, 2021
Refactor DivOverlay/Popup/Tooltip automation moved this from To do to Done Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants