pacificclimate / weather-anomaly-tool

0 stars 0 forks source link

Don't delete and then recreate map markers for each change #43

Open rod-glover opened 6 years ago

rod-glover commented 6 years ago

CAUTION: Do not embark on this optimization without profiling evidence that shows it is actually an issue.

Currently, when there is any change to the props that determine what data is displayed (variable, dataset, month, year), the baseline and monthly data arrays are emptied, then filled again with new values. This may inhibit React from rendering these changes efficiently.

The goal is to remove the data markers from the map while data is loading. This can be done alternatively by hiding the relevant Layer Groups, a much faster operation. This would improve performance if the markers themselves can be reused. It's not clear whether React has any influence on the Leaflet rendering of the markers, but it's possible. It's also possible that updating existing markers in Leaflet may be considerably faster than deleting and recreating them.