Difference between many Marker components and Source/Layer components #1511
-
If I'm using a map to plot markers with popups, custom icons, toggling marker visibility (turning categories of locations on/off) is there any reason to do this with I saw the note about performance on the Marker docs
If those are being cached (via |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
~100 Marker components should work fine if you use |
Beta Was this translation helpful? Give feedback.
~100 Marker components should work fine if you use
useMemo
. The main advantage of the React component is that you can define its content with arbitrary DOM and CSS, while a symbol layer's styling options are relatively limited. If you have hundreds of markers or more, it's definitely more performant to use source/layer, because the React component needs to update its position on every viewport change, while the layer is (I believe) cached by tile and is not as expensive to rerender.