Skip to content Skip to sidebar Skip to footer

Do Leaflet Maps Have A Label Function?

Anyone know whether it is possible to add a label beside my markers on my react-leaflet map?

Solution 1:

The link FrankerZ sent you to is pretty helpful, definitely check that out.

If you mean a little popup label that shows up when you hover over a marker (or Polyline, etc.) then as of Leaflet 1.0, you can use Tooltip. I've found that it works much more smoothly than making a Popup, and uses less code, especially if you're just opening the popup on hover. It might look like:

 var Marker = L.marker...
 Marker.bindTooltip('HI').openPopup();

And you can use the permanent boolean flag if you want to keep it open.

A less popup-y option is DivIcon, if you want a text label that stays at a certain position always. See this SO post. Basically you can add a div that is associated with a geographical position, then format the div to look as text-y or text box-y as you want.


Post a Comment for "Do Leaflet Maps Have A Label Function?"