Closed ninovanhooff closed 2 months ago
Hi @ninovanhooff ,
I am trying to adapt your code into the BasicMapActivity, and the gradient works on the polyline. The fact that the default value (black) is taken is a good candidate for a race condition where the polyline color can't be somehow determined and the fallback is chosen instead.
Could you provide a repository with a sample I can use to check it out?
Thanks.
I transplanted as much of BasicMapActivity into my own app as possible and still seeing the black line
I am migrating from xml to compose and have both the old and new dependencies in my project in different modules. My assumption now is that I have a dependency conflict where the old maps sdk is picked, which might not support span styles.
I am thus hoping/expecting that my problem will be resolved when removing the old Views-based maps dependency
Indeed!
Following these resources:
I found this line of code in my app:
MapsInitializer.initialize(applicationContext, MapsInitializer.Renderer.LEGACY, null)
Replacing that by
MapsInitializer.initialize(applicationContext)
Fixed the issue for me
Nice to hear. The original code was forcing the legacy renderer, and that would not work with the spanned polyline.
Android: 10, 14, physical + emulator. Probably all library version: 6.1.1 play-services-maps: 18.2.0 andoid-maps-utils 3.8.0
Steps to reproduce
Code example
Also tried defining colors like this:
Also tried omitting the
segments
parameter, and using a value ofpoints.size.toDouble()
per readme, but same effect. When using color = Color.Red I do see the expected red color.Also tried omitting the width and zIndex params.
In the source I noticed that black is the fallback color, and the color is applied after the spans. could that be the cause? https://github.com/googlemaps/android-maps-compose/blob/53830c5e406a66a52f29d928a4ed1d414febb3e1/maps-compose/src/main/java/com/google/maps/android/compose/Polyline.kt#L185 https://github.com/googlemaps/android-maps-compose/blob/53830c5e406a66a52f29d928a4ed1d414febb3e1/maps-compose/src/main/java/com/google/maps/android/compose/Polyline.kt#L166