Change GMSMapView default map background color in iOS
Asked Answered
C

2

4

The GMSMapView in iOS has a default background color of tan, or something like it.

I have a requirement to change that color to white. I've tried using a subclass of GMSTileLayer without success (or errors). I need to place custom map overlays with white backgrounds onto the map view. In areas without the overlays, the base map color needs to match (white).

Tried the following without any luck:

[mapView setBackgroundColor:[UIColor whiteColor]];

Can anyone offer suggestions, or point me to a resource (other than Google) that might help?

Thanks!

Castleman answered 13/10, 2015 at 15:18 Comment(1)
I think you can only change the mapType of your mapView, otherwise you have to use the GMSTIleLayer. Currently, you can not change the color of the mapView with the iOS SDK.Twandatwang
K
2

Now you can change GMSMapStyle of you map (available with Google Maps SDK for iOS 2.1). Styling works only on the kGMSTypeNormal map type. I create my own style with https://mapstyle.withgoogle.com/ Hope, it will help you.

Keratin answered 24/9, 2016 at 5:58 Comment(0)
E
1

As of release 8.3.0 (release notes), it is possible to override the default map background color by using the backgroundColor property that can be set on the GMSMapViewOptions object.

The documentation for the backgroundColor property states

Specifies the background color of the map view, which displays whenever the map tiles are not fully loaded.

It could look like this:

let options = GMSMapViewOptions()
options.backgroundColor = .red
let mapView = GMSMapView(options: options)
Elboa answered 27/11, 2023 at 20:10 Comment(1)
Is there any way of changing this after the map was initialized? Apparently if you give it a UIColor which supports both light/dark mode it only uses the theme it was initialized with. So you're stuck with only one color, even after user changed theme.Motheaten

© 2022 - 2024 — McMap. All rights reserved.