How can I keep map labels under a Polygon in Google Maps SDK for IOS?

111 Views Asked by At

Is there any way to keep the map labels with street names and POIs under GMSOverlays like GMSPolygons and GMSPolylines?

I have tried with different Zindex but to no vail.

This is what I get:

enter image description here

But as the polygon is the important thing here, I don't want the map labels on top of it, because they are, in my case, irrelevant. Besides I use a semitransparent fill color and you can still see the street names through it.

1

There are 1 best solutions below

0
Victor Alonso Barberan On

Answering my own question:

The only way I found was to add a Tile layer on top of the mapView like this:

mapView.mapType = .none // Set the map type to .none, as it will not be visible
    
let urls: GMSTileURLConstructor = { (x, y, zoom) in
    let url = "https://mt1.google.com/vt/lyrs=r&x=\(x)&y=\(y)&z=\(zoom)&scale=2"
    return URL(string: url)
}
let layer = GMSURLTileLayer(urlConstructor: urls)
layer.tileSize = 1024 // To get bigger fonts in mobile device with high resollution
layer.map = mapView

The only drawback is that when the map is rotated the labels are rotated too as you can see in this screenshot:

enter image description here