mapbox: TileOverlay PoC implementation#3481
Conversation
| // TODO: figure out how to remove this hack | ||
| Mapbox::class.java.getDeclaredField("moduleProvider").apply { | ||
| isAccessible = true | ||
| set(null, tileOverlayModuleProvider) | ||
| } |
There was a problem hiding this comment.
This is where I've had to use reflection
bb4fe3f to
b916efc
Compare
b916efc to
52feed3
Compare
52feed3 to
3c0eca5
Compare
|
Hi @depau, @mar-v-in — I only found #3481 and the #3058 discussion after I'd opened #3595, apologies for the parallel effort. Since we've both implemented Both solve the same core problem: MapLibre-Android's
On the caching point you flagged — apps using I'm not attached to mine winning — you clearly own this area and have the polyline/z-index work in flight. Happy to do whatever you and @mar-v-in prefer: fold the loopback bridge into #3481, close mine in favor of yours, or land mine standalone if a reflection-free, #3058-independent path is useful. What's your read? |
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: