Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 224
Victor Avatar asked Mar 12 '23 05:03

Victor


1 Answers

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)")
        } 
like image 161
Zarif Ahmed Avatar answered Mar 31 '23 10:03

Zarif Ahmed