2

When migrating from com.google.android.gms:play-services-maps:18.0.2 to com.google.android.gms:play-services-maps:18.2.0, my shapes suddenly started to appear behind the buildings and road labels, like this:

enter image description here

As you can see, both the lines (solid black, no transparency) and the area (solid green, no transparency) of this polygon is behind the buildings and labels.

Using version 18.0.2 of the library, this was not a problem. The polygon would then look like this:

enter image description here

Is this a bug in the new library version, or is it supposed to be like this? And is so, how can I get my shapes in front of the buildings and labels again? I tried using setZIndex(), but that did not help.

1 Answer 1

2

Use the setBuildingsEnabled(boolean) method and set it to false

There's an existing bug filed in the Google Public Issue tracker about this. And comment #7 states that this is working as intended with a workaround to disable the 3D buildings using the public method setBuildingsEnabled(boolean).

So in Kotlin, adding the following code to your onMapReady() should fix the issue with the SDK using the LATEST renderer / versions 18.2.0 and up (which uses the LATEST renderer by default. (See for more info: https://developers.google.com/maps/documentation/android-sdk/renderer)

override fun onMapReady(googleMap: GoogleMap) {

        googleMap.setBuildingsEnabled(false)

        //..... The rest of the code here .....//
}

Or you can also use the following in Kotlin:

override fun onMapReady(googleMap: GoogleMap) {

        googleMap.isBuildingEnabled = false

        //..... The rest of the code here .....//
}

This should prevent the overlay from overlapped by buildings again since they were disabled.

Proof of concept

NOTE: The Public Issue Tracker is the authoritative source of updates with regards to features/issues like this. So if this workaround does not work for you, I'd suggest that you star and upvote the issue mentioned above. And provide your use case / reason why the workaround discussed here does not suffice. This will help increase the visibility of the issue to the Google's engineers.

3
  • Thank you, but when I do "setBuildingsEnabled(false)", the buildings simply disappear (which I suppose should not be surprising). So in a way it fixes my problem, since the buildings are no longer in front of the polygons, since the buidlings aren't there anymore at all... Commented Feb 29 at 8:36
  • 2
    Yeah but unfortunately, that's the current official workaround that google adviced. But you can still add your use case on the bug if you think this kind of workaround does not work for you.
    – Yrll
    Commented Feb 29 at 23:28
  • 1
    Yes, I did that. Hopefully someone might fix it some day. Thanks for your suggestion! Commented Mar 1 at 10:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.