Repository navigation
Conversation
…y props Expose two Mapbox v11 raster source options that were not reachable from JavaScript: - prefetchZoomDelta: how many zoom levels above the current one are requested as placeholders while the current tiles load. 0 turns the prefetch off. - tileNetworkRequestsDelay: milliseconds to wait before a tile's network request goes out during a gesture or camera animation, so tiles that leave the viewport first are never requested. Both map straight to the native source builders on iOS and Android. Docs regenerated with yarn generate, and a new example scene uses both props. Co-Authored-By: Claude Fable 5.1 <[email protected]>
mfazekas
left a comment
There was a problem hiding this comment.
Thanks, this is useful and the wiring matches tileSize on both platforms. A few changes before merging:
- Android:
setPrefetchZoomDelta/setTileNetworkRequestsDelayinRNMBXRasterSourceManagercallasInt()/asDouble()without checkingvalue.isNull. If an app sets one of these props and later removes it, Fabric passes a nullDynamicand the call throws. Please skip (or reset tonull) when the value is null. - The
prefetchZoomDeltadoc says tiles "up to this many zoom levels above it" are requested. Per the SDK, the map first requests a single lower-zoom tile, at a zoom belowzoom - deltarounded to a multiple ofdelta, to show a coarse map quickly. Please align the wording with that. - Both props are only read when the source is created, so changing them after mount has no effect. Please say so in both docs.
- The example uses
tile.openstreetmap.orgwith no attribution; OSM's tile usage policy requires it and discourages app traffic. Either addattributionon the source or reuse the tile URL from the existingRasterSourceexample.
We'll also check the Android side at runtime on an emulator, since it has only been compile-checked so far.
…efetch-and-network-delay
…docs, add example attribution
|
Thanks @oliverfernandez! Since this has been quiet for a while, we have taken it over and pushed the remaining review fixes on top: null-safe prop removal on Android, corrected |
mfazekas
left a comment
There was a problem hiding this comment.
Review fixes are in; verified on Android.
|
@mfazekas Thank you for merging. My Github notifications are a mess, and I didn't receive a notification when you posted your comment |
Description
Added
prefetchZoomDeltaandtileNetworkRequestsDelayprops toRasterSource. They expose two Mapbox v11 raster source options that are set today only by the SDK defaults:prefetchZoomDelta: when greater than 0, the map first requests a tile at a zoom level belowzoom - delta, rounded to a multiple of the delta, to show a low-resolution map quickly. Mapbox defaults to 4.0turns the prefetch off, which suits overlays such as weather radar where the placeholder is never visible.tileNetworkRequestsDelay: milliseconds to wait before a tile's network request goes out while a gesture or camera animation is in progress. Tiles that leave the viewport before the delay elapses are never requested. Mapbox defaults to 0.Both map straight to
RasterSource.prefetchZoomDelta/tileNetworkRequestsDelayon iOS andRasterSource.Builder.prefetchZoomDelta()/tileNetworkRequestsDelay()on Android. They are read when the source is created, like the other source props.Motivation: a weather app with 25 raster frames at one camera position. With the defaults, each frame also fetched parent tiles it never showed, and a pan requested tiles for positions the finger had already left. With these two options the same open costs a quarter of the tile requests.
Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Testing notes: verified on iOS (v11, New Architecture) and compiled on Android (v11, New Architecture) through a production React Native 0.81 app that consumes this branch as a patch: the Fabric codegen picks up the new spec props, the component view and the Swift source compile, the Kotlin manager and source compile, and the raster tiles render on the iOS simulator with
prefetchZoomDelta={0}andtileNetworkRequestsDelay={200}. A proxy capture on iOS confirmed that only tiles of the current zoom level are requested. Android was compile-checked only; the new example sceneRasterSourceTileRequestsis the place to confirm it at runtime.Screenshot OR Video
No visual change. The example scene
Fill/Raster Layer > Raster Source tile requestsshows the props in use; compare the network log withRaster Sourcewhile panning.