mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
430 stars 126 forks source link

[11.3.1][Compose][Vector tiles] Builder doesn't initialize tiles url to VectorSourceState - "[maps-android\SourceState]: Failed to add source: source must have tiles" #2362

Closed RyPope closed 1 month ago

RyPope commented 1 month ago

Environment

Observed behavior and steps to reproduce

I've been using compose on a new project and recently updated to 11 and refactored it to use VectorSource/VectorSourceState etc. Things were working prior to this but I've been unable to get things working again. I think based on debugging that the actual builder itself is not initializing the url.

Code

  val vectorTileSource = rememberVectorSourceState(selectedUserId) {
    VectorSource.Builder("run")
      .tiles(listOf("https://tiles.myrunmap.com/${selectedUserId}/tiles/{z}/{x}/{y}.pbf"))
      .minimumTileUpdateInterval((60 * 5).toDouble())
      .volatile(true)
      .build()
  }

With this I see no network requests, and i get the error [maps-android\SourceState]: Failed to add source: source must have tiles

When I debug a line below it

Log.d("Ryan", "Tiles: " + vectorTileSource.tiles.value)

This is the result in the debugger showing that the tiles are not being set on the vector source

Screenshot 2024-05-03 at 12 53 09 AM

Expected behavior

Network requests should be firing to my tile server

Notes / preliminary analysis

I found the actual error in the native code, indicating that the tiles field is empty. It's clearly being set in the code above. I'm not privy to the compose builder code so I can only deduce that there may be a bug in the builder.

https://github.com/mapbox/mapbox-gl-native/blob/f2778251c97ba3403582b9c04290c50f927fd338/src/mbgl/style/conversion/tileset.cpp#L15