Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rerender map without cached tiles #487

Open
wmonecke-oss opened this issue Nov 11, 2024 · 2 comments
Open

Rerender map without cached tiles #487

wmonecke-oss opened this issue Nov 11, 2024 · 2 comments

Comments

@wmonecke-oss
Copy link

wmonecke-oss commented Nov 11, 2024

Steps to Trigger Behavior

  1. Make the map re-render with fresh tiles (data) on value change

Expected Behavior

Expect the map to re-render with new tiles (fresh data).

Our use case is that we have a WebSocket that notifies the app that it needs fetch new data for the tiles since the color/data of the current "zones" has changed. Say it went from red to yellow.

I have looked through the docs but do not see a method to do something like:

maplibreCache.invalidate()

This would then trigger new fetch requests for new tiles and discard cached data.

Currently, I am just changing the key i have attached to <MapLibreGL.MapView key=${rerender.key}`/> and the map does re-render but very inconsistently and this feels hacky at best. I have attached a video of the current behavior.

What would the right way to do this?

Actual Behavior

Map seems to keep previous data and renders partially cached data

Screenshots (if applicable)

RPReplay_Final1731327140.1.mp4

Environment

  • Platform: iOS & Android
  • OS version: iOS 18
  • Device type: iPhone 15 Pro Max
  • Emulator or Simulator: no
  • Development OS: macOS Sonoma
  • "@maplibre/maplibre-react-native": "9.1.0",
  • react-native Version: 0.74.2

Additional context

I think Mapbox has something like:

 mapRef.current?.clearData();
@KiwiKilian
Copy link
Collaborator

KiwiKilian commented Nov 11, 2024

From the description, this method could fix it:

await MapLibreGL.offlineManager.invalidateAmbientCache();

@wmonecke-oss
Copy link
Author

wmonecke-oss commented Nov 11, 2024

Hey @KiwiKilian! Will try that and report back, thank you for answering. I thought that the offlineManager would only work if you actively managed packs etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants