From 38a7d4047d994f6a97da101e5d84041351244072 Mon Sep 17 00:00:00 2001 From: Felix Goudreault Date: Fri, 28 Mar 2025 10:25:16 -0400 Subject: [PATCH 1/2] allow custom toolbar tooltips --- src/ts/react-leaflet/EditControl.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ts/react-leaflet/EditControl.ts b/src/ts/react-leaflet/EditControl.ts index a8645d6..13fd8e2 100644 --- a/src/ts/react-leaflet/EditControl.ts +++ b/src/ts/react-leaflet/EditControl.ts @@ -22,6 +22,11 @@ export type EditControlProps = { */ edit?: object; + /** + * Customize toolbar button tooltips. See default values here https://github.com/Leaflet/Leaflet.draw/blob/master/src/Leaflet.draw.js#L99 + */ + buttons?: object; + // Custom properties. /** @@ -73,7 +78,7 @@ const manipulateToolbar = (toolbar, mode, action) => { function createEditControl(){ function createDrawElement(props, ctx) { const {layerContainer} = ctx; - const {draw, edit, position} = props; + const {draw, edit, buttons, position} = props; const options = { edit: { ...edit, @@ -86,6 +91,9 @@ function createEditControl(){ if (position) { options["position"] = position; } + if (buttons) { + L.drawLocal.draw.toolbar.buttons = buttons; + } return createElementObject(new L.Control.Draw(options), ctx) } function updateDrawElement(instance, props, prevProps) { From 5411856d4718d11e257ae3be9ac2f6f6224f8c99 Mon Sep 17 00:00:00 2001 From: Felix Goudreault Date: Fri, 28 Mar 2025 10:40:19 -0400 Subject: [PATCH 2/2] don't overwrite default values --- src/ts/react-leaflet/EditControl.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ts/react-leaflet/EditControl.ts b/src/ts/react-leaflet/EditControl.ts index 13fd8e2..4b83ddc 100644 --- a/src/ts/react-leaflet/EditControl.ts +++ b/src/ts/react-leaflet/EditControl.ts @@ -92,7 +92,9 @@ function createEditControl(){ options["position"] = position; } if (buttons) { - L.drawLocal.draw.toolbar.buttons = buttons; + L.drawLocal.draw.toolbar.buttons = { + ...L.drawLocal.draw.toolbar.buttons, ...buttons + } } return createElementObject(new L.Control.Draw(options), ctx) }