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

Adding Label To Center Position #84

Closed
agus-prawoto opened this issue Jul 1, 2014 · 1 comment
Closed

Adding Label To Center Position #84

agus-prawoto opened this issue Jul 1, 2014 · 1 comment

Comments

@agus-prawoto
Copy link

Hi, I try to add this code to label.js and bringing label to the center position of circleMarker
not tested in Marker. I Think it would be nice to add feature to the plugin that can put the label in the center position (center-top or center-bottom)

           // center
    if (direction === 'center') 
    {
        distance = this.options.distance || 5;
        mark_height = this._source._radius + (labelHeight/2) + distance;
        L.DomUtil.addClass(container, 'leaflet-label-center');
        L.DomUtil.removeClass(container, 'leaflet-label-left');
        L.DomUtil.removeClass(container, 'leaflet-label-right');
        pos = pos.add(L.point(-offset.x - (labelWidth /2) + offset.x, offset.y - mark_height));
    // position to the right (right or auto & needs to)
    } else if (direction === 'right' || direction === 'auto' && labelPoint.x < centerPoint.x) { ... }

circle

@jacobtoye
Copy link
Member

There is a pull with code to do this already: #60

I haven't had a chance to check it out yet but you could use this in the meantime.

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

No branches or pull requests

2 participants