Closed johnghr closed 1 year ago
I've found a solution to this is to force the MapboxMap component to rerender when the style changes
Reopening as a feature request for next update.
Just reloading layers and sources should be much more efficient than reloading the entire component, and will make changing styles simple.
Also, you can use the new beforeLayer
prop to ensure layer order.
Awesome! You're also a mind reader because I was 100% going to ask about the layer order.
Fixed in #45
I was just wondering if you had any suggestions regarding how to handle changing the the map style with the mapbox setStyle method while using the MapboxLayer and MapboxSource components? The problem being if I access the map instance with useMapInstance and set the style, my MapboxLayer and MapboxSource components become redundant because the data gets removed when the map gets reinstantiated.
Is there a way to use the components and progmatically set the style or is just using vanila mapbox-gl recommended for this use case?