w8r / leaflet-labeled-circle

Special type of SVG marker with a label inside and draggable around the anchor point
https://w8r.github.io/leaflet-labeled-circle/demo/
MIT License
42 stars 10 forks source link

Allow options for SVG getBBox call #39

Closed crh3675 closed 8 months ago

crh3675 commented 8 months ago

I implemented this plugin but when a stroke is around the circle, the text is horizontally offset.
image

The fix is to update the getBBox call to include the stroke:

https://github.com/w8r/leaflet-labeled-circle/blob/master/src/circle.js#L168

const bbox = textElement.getBBox({stroke: true, markers: true);

Would be nice to expose that as an option to the base implementation

        return L.labeledCircleMarker(latlng, feature, {
          markerOptions: {
            fillOpacity: 1,
            shiftY: 5,
            bboxOptions: {
              stroke: true,
              markers: true
            },
            textStyle: {
              fontSize: 10,
              color: color.color
            },