visgl / react-map-gl

React friendly API wrapper around MapboxGL JS
http://visgl.github.io/react-map-gl/
Other
7.88k stars 1.35k forks source link

Unable to perform style diff: Rebuilding the style from scratch #497

Closed MattReimer closed 6 years ago

MattReimer commented 6 years ago

A little background: I'm building an app that requires layer management. I'm trying to add and remove layers from the map using switches and toggles.

My strategy has been to hold a mapStyle object in the redux state, then use redux actions and reducers to add/remove layers and then pass the whole mapstyle into my map as a prop like this:

<ReactMapGL id='appMap' mapStyle={mapStyle} />

My thought was that ReactMapGL would detect the differences and just pass them on to MapBoxGL but when I modify the mapStyle I'm seeing the entire map and all its layers reload which is time-consuming and very distracting.

In the browser console I get the error:

Unable to perform style diff: Unimplemented: setLayerProperty, setLayerProperty..  
Rebuilding the style from scratch.

So I can't help but wonder if I should be modifying the style some other way. Has anyone found a way around this?

Note: I think this may related to #116 but I'm not 100% sure

Pessimistress commented 6 years ago

@MattReimer Is your mapStyle an Immutable map? If not, can you give it a try?

116 is something we are still working on.

jefferymills commented 6 years ago

@MattReimer Were you able to solve this issue? We're experiencing the same thing currently and we are using Immutable.

daquintero commented 6 years ago

Same as well!

sabres207 commented 2 years ago

can you explain what do you mean by using Immutable? I'm currently having this issue in an app I'm developing. We use a url for mapStyle, so I'm not sure what an Immutable map actually mean in that context.

Would appreciate any help. thanks!

jefferymills commented 2 years ago

@sabres207 it's in reference to the Immutable.js library. Often used in conjunction with a state management library like Redux. Immutable map.

Hopefully that answers your question.

sabres207 commented 2 years ago

@jefferymills Thanks, yea I figured you were talking about Immutable.js, but I'm not sure how exactly should I use it and why would it work? because the map style is only a url. should I use Immutable map to hold that style url?