Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Allow center-position of Labels #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Allow center-position of Labels #60

wants to merge 2 commits into from

Conversation

crrobinson14
Copy link

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.

@jacobtoye
Copy link
Member

Have you checked out #55? I have to find some time to review that pull, but I think it will provide this functionality.

@crrobinson14
Copy link
Author

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...

@Arxi
Copy link

Arxi commented Sep 7, 2014

Will this be merged?

@ceesvanegmond
Copy link

Is this going to be merged?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants