iosswiftstylesgmsmapview

Swift Map styling with GMS


Im using GMS (Google Maps SDK) In my current project, and it looks like this

Is it possible to style the map to something like this? and still use GMS.


Solution

  • You can customize the map the way you want here: https://mapstyle.withgoogle.com/

    Once you are done with customization, copy the json and add it your project in a file say style.json

    Then assign this styling to your map as:

    do {
                // Set the map style by passing the URL of the local file.
                if let styleURL = Bundle.main.url(forResource: "style", withExtension: "json") {
                    mapView.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
    
                } else {
                    NSLog("Unable to find style.json")
                }
            } catch {
                NSLog("One or more of the map styles failed to load. \(error)")
            }