I am showing a world map in react using highcharts and I am showing lot of bubbles(data points) on the map. When the user clicks zoom in button, the map takes some time to zoom in with large number of bubbles on the map. I want to add a loading message when the map is zooming in so that the user doesnt click the zoom in button again and again. I am trying to add a function for onClick on zoomin button as below, where I set a state for the loader and toggle it. However I see, once the loader goes away, the map is reset to its original size
const options = useMemo(
...
mapNavigation: {
enabled: true,
enableButtons: true,
enableMouseWheelZoom: false,
enableDoubleClickZoom: true,
buttons: {
zoomIn: {
onclick: function () {
setZoomLoad(true) //setting loader state
const chart = this as any
setTimeout(() => { setZoomLoad(false); chart.mapZoom(0.5); }, 3000)
}
}
}
}
return (zoomLoad) ? (
<div>Loading...</div>
) : (
<WorldMapComp options={options} chartRef={chartRef} />
)
I also tried setting a useEffect with redraw to check if will render the map with zoom like below , which didnt work
useEffect(() => {
// After re-rendering, restore the zoom level
if (chartRef) {
chartRef.current.chart.mapZoom = 0.5 as any;
chartRef.current.chart.redraw();
}
}, []);