mapbox: TileOverlay PoC implementation#3481
Open
depau wants to merge 6 commits into
Open
Conversation
depau
commented
May 17, 2026
Comment on lines
+195
to
+199
| // TODO: figure out how to remove this hack | ||
| Mapbox::class.java.getDeclaredField("moduleProvider").apply { | ||
| isAccessible = true | ||
| set(null, tileOverlayModuleProvider) | ||
| } |
Author
There was a problem hiding this comment.
This is where I've had to use reflection
bb4fe3f to
b916efc
Compare
depau
commented
May 18, 2026
b916efc to
52feed3
Compare
52feed3 to
3c0eca5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi!
I got to writing a proof-of-concept implementation for the Google Maps
TileOverlaysas discussed here: #3058 (comment)To make the tile overlays work, I implemented an HTTP request class that intercepts requests to a special invalid domain under microg.org (though anything that can't be registered works).
Once the request is intercepted, the class determines which
TileProviderit should get the data from, it fetches the data, encodes it as PNG if necessary, then returns a fake HTTP response with the payload.In the current implementation I went out of my way to work around Mapbox's internal caching system, forcing it to not cache any of the custom tiles and instead implement a LRU cache in the interceptor class.
This is because a few apps rely on the
TileOverlay.clearTileCache()to drop caches and re-render all custom tiles currently displayed, but Mapbox refuses to actually reload the images unless you make it absolutely necessary.Why is this a PoC?
https://github.com/microg/GmsCore/pull/3481/changes#diff-06766ea2baeef42a2fc47e09f2d8e70cca8951e51c08bd010b5ef4ada9f31073R195-R199
It looks like the version of Mapbox in use, which I imagine is locked for SDK compatibility reasons, doesn't expose the method to update the moduleProvider implementation (and with it the HTTP request implementation), although later versions do.
To test the feasibility of the implementation I went ahead and used reflection to move forward, but I haven't found a cleaner way to do it.
This PR depends on #3058 and therefore it includes all commits from that PR. When reviewing, be sure to only check the last commit, which is the only difference between this and the other PR.
Some screenshots
Screenshots (click to expand)
My tile overlay test app: https://github.com/depau/gmaps-tile-overlay-demo
(Please note the screenshots are from 3 different devices, and that the overlay tile borders are not DPI-aware)
Before:
GApps:
After:
My local transport app:
Before:
After: