Leaflet.label icon indicating copy to clipboard operation
Leaflet.label copied to clipboard

showLabel() does not work with a Circle

Open MikeTommasi opened this issue 10 years ago • 3 comments

similar to comment on polygon, label works but showlabel throws error.

I understand the issue with polygons (where to center), but in this case a Circle DOES have a center and a radius defined, so should be easier to include. Hopeful.

nice work anyhow

MikeTommasi avatar Mar 18 '14 20:03 MikeTommasi

This is actually somewhat critical because the Circle constructor uses a radius in meters which is much nicer than circleMarker's radius in pixels.

ghost avatar Aug 09 '14 01:08 ghost

We could do static labels for L.Circle's. However the way Leaflet.label currently works you cannot have both the vector behavior (the label follows the mouse) and the marker behavior (the label shows at the center).

As a quick fix you can include the following code:

L.Circle.mergeOptions({
    labelAnchor: new L.Point(0, 0)
});

L.Circle.include(L.BaseMarkerMethods);

This will make markers on circles show at the center and support the noHide option. However when noHide = false is used the label will only appear at the center (not useful for large circles).

jacobtoye avatar Aug 12 '14 22:08 jacobtoye

Thanks, that helps a lot.

ghost avatar Aug 13 '14 00:08 ghost