How to re-initialize source and layer after changing map style using react map gl library

Viewed 121

I am trying to change map view from streets to satellite view using react map gl library components but getting console errors of compiler not able to find source for corresponding layers. I have used by default Source and layer component of this library which works fine on initial page load but doesn't seems to work on changing map style. Moreover the layers are displayed fine on the map even after compiler generating console errors for same.

Can someone help me to diagnose the reason behind it and resolve it out completely.

Source Code

Console Errors

Another console error

1 Answers

Finally I have found the solution for it after a research. There is a prop present in ReactMapGL component of react map gl library named preventStyleDiffing which if set to true would prevent internal library code to find the difference in style properties whenever we try to switch map style from one option to another. Following this approach cleared the compiler generated issues for me.

Related