Is it possible to draw features on top of other features without re-rendering the original features?
See original GitHub issueHi, I understand that the topic question might be a bit confusing. Here is a clarification of what I am now doing:
- I draw 10,000
features
(circles) on a map. - I draw another 10,000 circles on a map and it erases the original 10k circles.
I know that I can keep an array and continuously push to it, e.g.
- Draw the original 10k circles on the map from an array
points
. - Push the next 10k circles into
points
and draw all 20k circles.
This isn’t my goal because I don’t want to redraw the original points on the map. My reason for drawing the circles 10k at a time is due to performance optimizations and other constraints.
So here’s my question: Can I draw the new 10k circles on the map without erasing/redrawing the original 10k points?
Also if anyone has other ideas for the issue title then I’ll gladly change it. Just couldn’t think of a better one!
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
5 Ways to Avoid React Component Re-Renderings
It is commonly used with Redux stores and has amazing features to reduce unnecessary re-renderings. Reselect selectors are capable of computing derived data ......
Read more >Just Say No to Excessive Re-Rendering in React - GrapeCity
In this article, we will address instances of excessive re-rendering in React applications and demonstrate how to avoid them.
Read more >Update search params without re-rendering everything · Issue ...
In short, the app updates query-string parameters (e.g., selected object id in a table) so if the user reloads the browser, or copies...
Read more >When does React re-render components? - Felix Gerschau
This process of comparing the old VDOM with the new one is called diffing. Real DOM updates are slow because they cause an...
Read more >Feature Toggles (aka Feature Flags) - Martin Fowler
Feature Toggles (often also refered to as Feature Flags) are a powerful technique, allowing teams to modify system behavior without changing code.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I might have initially misunderstood your problem a bit.
What you can do is have two separate layers on the map, one for each of your network fetches.
Now, if pointsB appears in the state (after a network request), react-mapbox-gl will only create that layer, keeping the
points-a
layer as-is.The reason for suggesting the two layers was that it should be slightly more performant, because mapbox doesn’t have to initialize the first set of points twice. In general yes, just pushing to an array in the component state is definitely the easiest way to add data from two network requests.
Mapbox itself has some docs on optimizing for large data sets: https://docs.mapbox.com/help/troubleshooting/working-with-large-geojson-data/