react-map-gl icon indicating copy to clipboard operation
react-map-gl copied to clipboard

SVGOverlay redraw() function gets called when unnecessary

Open Snorlite opened this issue 7 years ago • 3 comments

I read that the SVGOverlay redraw() function gets called every time the map updates, but it seems to get called steadily even when I don't change the map viewport. Taking the example from the docs:

import {SVGOverlay} from 'react-map-gl';

function redraw({project}) {
  console.log("test"); // the print of this message doesn't stop when I don't change the map viewport
  const [cx, cy] = project([-122, 37]);
  return <circle cx={cx} cy={cy} r={4} fill="blue" />; // I think redrawing this circle when I don't change the map viewport makes no sense
}

<MapGL {...viewport}>
  <SVGOverlay redraw={redraw} />
</MapGL>

I want the function redraw() to get called only at the launch of the application and when I change the viewport.

Snorlite avatar Jul 09 '19 15:07 Snorlite

I cannot reproduce this. Do you have other prop/state change on MapGL?

Pessimistress avatar Jul 12 '19 17:07 Pessimistress

I cannot reproduce this. Do you have other prop/state change on MapGL?

No

Snorlite avatar Jul 12 '19 17:07 Snorlite

Closing for inactivity. Will reopen if you can provide a code sandbox to reproduce the issue.

Pessimistress avatar Nov 02 '20 16:11 Pessimistress