This question is for those who understand the insides of MapBox GL JS.
I use MapBox GL JS to render a geographic map of up to 40,000 polygons, each of which is colored based on the "owner" of this polygon. Usually there are many polygons per owner, and the "owner" of each polygon can change over time. The number of owners can vary from one to 1000. I have performance problems (which vary depending on how I approach it), so I tried several different strategies.
- Using data driven styles for "fill-color" where I have a single source and one layer. I tried both the polygon identifier and the owner identifier as a category for the data driven style.
- Using filtered layers, where I have a single source and a separate layer for each "owner". Again, I tried both the polygon identifier and the owner identifier as filter criteria.
- Using a separate source and level for each "owner".
Option 3 has the best drawing speed. Layers display very quickly when I zoom in and pan. But I have to call setData whenever I change the owner of the layer and setData of a memory leak, so I end up crashing the page. This question, 2607, has been closed as invalid, so I do not expect permission to do so.
Options one and two draw in order with the original zoom, but when I zoom in, they are very slow to re-draw the tiles. I was stuck looking at the jagged, low-detailed tiles until the rendering caught up in 20-30 seconds. Please note: if I use the identifier "owner" instead of the "polygon" id, I still need to call setData when the "owner" changes, which will lead to a memory leak. If I use the polygon identifier, I just need to update the layer filters or fill colors when changing the "owner". However, I do not see a noticeable difference in performance if I use the identifier "polygon", so I think that everything is in order.
So my question is why option 3 is rendered much faster when I zoom in? Does this relate to the number of workers assigned to paint? In variants one and two there is one source, does this mean that the picture is used only by one worker? If in the third option there is a separate source for each "owner", so I have several workers who make the drawing?
source share