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

[Feat] Force `fresh=true` on fetched styles #2121

Open tordans opened 1 year ago

tordans commented 1 year ago

Target Use Case

When using a Mapbox Style URL like mapStyle="mapbox://styles/foo/123" the results are cached.

I am looking for a way to force a fresh version of the styles.

The Mapbox Style API has the (undocumented) fresh=true param for this use case (see https://github.com/mapbox/mapbox-sdk-js/issues/364#issuecomment-617894314).

However, I don't see any way to pass this to mapbox-gl or maplibre-gl.

I tried manually fetching the same style URL that I see being fetched from the console and appending ?fresh=true, but it looked like that was not picket up by the map. Maybe because I change the URL when adding the flag?

Proposal

Ideally, I would be able to call <Map mapStyle="" fresh={true} /> (with true being evaluated by some condition (like a debug flag) internally).