3

I need to add a label to marker from bottom. But there are no any value to add for direction option in bindLabel method.

 var marker = L.marker([ latitude, longitude ], {
         icon : iconInfo,
         iconAnchor: [10, 10],
         labelAnchor: [6, 0]
     }).bindLabel(displayingText, {
         direction: 'right',
         noHide : true
     }).addTo(leaf_map);

It only have right|left|auto options only. How can I achieve this with leaflet marker ?

2 Answers 2

4

The method bindLabel from the plugin Leaflet.label is deprecated but its functionality was included in Leaflet core from version 1.0 using tooltip.

This should work within your code:

var marker = L.marker([ latitude, longitude ], {
         icon : iconInfo,
         iconAnchor: [10, 10],
         labelAnchor: [6, 0]
     }).bindTooltip(displayingText, {
         direction: 'bottom',
         permanent : true
     }).addTo(leaf_map);
0

I think you can use the offset option of leaflet.Label

offset: Position offset from the marker icon's labelAnchor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.