From 5391b2a34cbbf3f32cb81ef06d52c9fb194f105e Mon Sep 17 00:00:00 2001 From: James Lyne Date: Sat, 15 Jan 2022 16:00:19 +0000 Subject: [PATCH] Recreate tooltips on marker update --- src/util/areas.ts | 11 ++++++++++- src/util/circles.ts | 12 +++++++++++- src/util/lines.ts | 12 +++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/util/areas.ts b/src/util/areas.ts index 4fbbed0..3008a78 100644 --- a/src/util/areas.ts +++ b/src/util/areas.ts @@ -62,7 +62,16 @@ export const updateArea = (area: LiveAtlasPolyline | LiveAtlasPolygon | undefine area.closePopup(); area.unbindPopup(); - area.bindPopup(() => createPopup(options, 'AreaPopup')); + area.closeTooltip(); + area.unbindTooltip(); + + if (options.popup) { + area.bindPopup(() => createPopup(options, 'AreaPopup')); + } + + if (options.tooltip) { + area.bindTooltip(() => options.tooltipHTML || options.tooltip, tooltipOptions); + } if(dirty) { area.redraw(); diff --git a/src/util/circles.ts b/src/util/circles.ts index 39bfe7a..817ea42 100644 --- a/src/util/circles.ts +++ b/src/util/circles.ts @@ -48,7 +48,17 @@ export const updateCircle = (circle: LiveAtlasPolyline | LiveAtlasPolygon | unde circle.closePopup(); circle.unbindPopup(); - circle.bindPopup(() => createPopup(options, 'CirclePopup')); + circle.closeTooltip(); + circle.unbindTooltip(); + + if (options.popup) { + circle.bindPopup(() => createPopup(options, 'AreaPopup')); + } + + if (options.tooltip) { + circle.bindTooltip(() => options.tooltipHTML || options.tooltip, tooltipOptions); + } + circle.setStyle(options.style); circle.setLatLngs(getCirclePoints(options, converter, outline)); circle.redraw(); diff --git a/src/util/lines.ts b/src/util/lines.ts index c3e6a6e..b31943d 100644 --- a/src/util/lines.ts +++ b/src/util/lines.ts @@ -44,7 +44,17 @@ export const updateLine = (line: LiveAtlasPolyline | undefined, options: LiveAtl line.closePopup(); line.unbindPopup(); - line.bindPopup(() => createPopup(options, 'LinePopup')); + line.closeTooltip(); + line.unbindTooltip(); + + if (options.popup) { + line.bindPopup(() => createPopup(options, 'AreaPopup')); + } + + if (options.tooltip) { + line.bindTooltip(() => options.tooltipHTML || options.tooltip, tooltipOptions); + } + line.setStyle(options.style); line.setLatLngs(options.points.map(projectPointsMapCallback, converter)); line.redraw();