Leaflet.label
Leaflet.label copied to clipboard
Allow center-position of Labels
This pull request adds a 'center' option for 'position' that shifts the Label half its width rather than all or none of it. This can be used to horizontally center a Label, e.g. by:
var mapCenter = map.getCenter();
var label = new L.Label({
classname: 'heading',
direction: 'center',
offset: [0, 0]
});
label.setContent('My Heading');
label.setLatLng([51.6, mapCenter.lng]);
map.showLabel(label);
The vertical position is still up to the caller - Label only calculates its width, not its height.
Have you checked out https://github.com/Leaflet/Leaflet.label/pull/55? I have to find some time to review that pull, but I think it will provide this functionality.
I didn't read it thoroughly yet but at first glance they seem similar. In the comment trail there seems to be some confusion about why this is required. autoVertical isn't a complete answer. My use case is for things like legends and headings where you want to put something in a fixed lat/lng rather than having the system guess whether to bump it up or down...
Will this be merged?
Is this going to be merged?