Skip to content

mapbox: TileOverlay PoC implementation#3481

Open
depau wants to merge 6 commits into
microg:masterfrom
depau-forks:feature/mapbox-tile-overlays
Open

mapbox: TileOverlay PoC implementation#3481
depau wants to merge 6 commits into
microg:masterfrom
depau-forks:feature/mapbox-tile-overlays

Conversation

@depau
Copy link
Copy Markdown

@depau depau commented May 17, 2026

Hi!

I got to writing a proof-of-concept implementation for the Google Maps TileOverlays as 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 TileProvider it 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: Screenshot_20260517-022624

GApps: Screenshot_20260517-022531_GMaps Tile Overlay Demo

After: Screenshot_20260517-022349_GMaps Tile Overlay Demo

My local transport app:

Before: image

After: Screenshot_20260517-020546_ATM Milano

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)
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where I've had to use reflection

@depau depau force-pushed the feature/mapbox-tile-overlays branch from bb4fe3f to b916efc Compare May 17, 2026 19:43
@depau depau force-pushed the feature/mapbox-tile-overlays branch from b916efc to 52feed3 Compare May 21, 2026 17:12
@depau depau force-pushed the feature/mapbox-tile-overlays branch from 52feed3 to 3c0eca5 Compare May 21, 2026 17:18
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

Successfully merging this pull request may close these issues.

1 participant