Skip to content

WmsUrlTileProvider(EPSG:3857) class that is a subclass of UrlTileProvider and a WmsTileOverlay composable that wraps TileOverlay and uses said provider. #880

Closed

Description

@munw37

Is your feature request related to a problem? Please describe.
While doing a student-app-project mandatory APIs were on WMS EPSG3857 format. Seeing the general ease of use of the GoogleMap-composable and some previous knowledge I had about WMTS I figured I could just convert as I learned more about the WMS-format. Checking the network requests made by the MapLibre example provided to us I saw that it in fact did query the WMS-API in a square tile-based manner too.

Describe the solution you'd like
I have written code for:
A URL-tile provider subclass that takes a urlFormatter-lambda with arguments for the bounding-box (xMin,yMin,xMax,yMax) that returns a string, so that the programmer can dictate the formatting of the URLs sent from the tile provider to the tile overlay.
To make it efficient the provider uses bit shifting for powers of 2 used in BBOX calculations. (IE finding the amount of tiles across for a given zoom-level)
Another efficiency is that if given bounds of the API the overlay is showing, the provider will return null in place of URLs pointing to tiles outside of the APIs bounds foregoing a "doomed" network request.

I also wrote a TileOverlay-wrapper that sets up its own TileProvider, with the only requirement of a urlFormatter-lambda it can pass down to the provider.

Describe alternatives you've considered
Just providing a URL-tile provider subclass though why not give a working TileOverlay-wrapper too.
Letting programmers make this themselves when they need it.
Discouraging WMS use so that API-providers all start serving WMTS instead.

Additional context
This seems like something that could easily have been provided already so it would be interesting to hear why it isn't (as far as I could tell from my research). I have checked for distortion at high latitudes where it would be the most pronounced, but I can't detect any.

Here is the urlFormatter definition and how I pass it in my app:
In WmsUrlTileProvider constructor:
private val urlFormatter: (
xMinBound: Double,
yMinBound: Double,
xMaxBound: Double,
yMaxBound: Double
) -> String

The lambda I pass it as an argument:
val geologyApiUrlFormatter = { xMin: Double, yMin: Double, xMax: Double, yMax: Double ->
"$geologyApi$graniteLayer&BBOX=$xMin,$yMin,$xMax,$yMax" }

Activity

  1. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    triage meI really want to be triaged.
    on Mar 27, 2026
  2. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    and removed
    triage meI really want to be triaged.
    on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions