From ba4a95825bdad17033c22a384fccd359e39d4aa3 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Wed, 18 Jun 2025 19:12:00 +0000 Subject: [PATCH] reset the map when new parameters are chosen --- crawler/frontend/src/components/Map.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crawler/frontend/src/components/Map.tsx b/crawler/frontend/src/components/Map.tsx index 6daa3c2..72ef041 100644 --- a/crawler/frontend/src/components/Map.tsx +++ b/crawler/frontend/src/components/Map.tsx @@ -60,7 +60,7 @@ export function Map( return () => { mapRef.current.remove() } - }, []) + }, [data]) function clone(d) { @@ -155,7 +155,10 @@ export function Map( * @type {number} */ var svg_height = 300, svg_width = 70; - var svg = d3.select('#svg'); + // clear svg before starting + d3.select('#svg').selectAll('*').remove(); + // create a new SVG element + const svg = d3.select('#svg'); var defs = svg .attr('height', svg_height) .attr('width', svg_width); @@ -215,7 +218,6 @@ export function Map( for (let property of properties) { listingComponents.push(getPropertyComponent(property)); } - console.log(listingComponents.length) return