I customized google map's appearance with Styling Wizard. It told me to copy the JSON, which I did, but I have no idea where to implement it in my iOS Swift project.
Does anyone know where to put it?
Thanks!
You can use this piece of code in order to create stylish maps where you have created the GoogleMaps
object mapView
Swift 3.x code
do {
// Set the map style by passing the URL of the local file. Make sure style.json is present in your project
if let styleURL = Bundle.main.url(forResource: "style", withExtension: "json") {
mapView.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
} else {
print("Unable to find style.json")
}
} catch {
print("The style definition could not be loaded: \(error)")
}
The link you posted as Styling Wizard will be used to create a json
file. Modify your map and create a json. Then copy the json
and create a new plain text file and paste the json. Give the file name style.json. Copy the .json file in your project and use the above code to change the style of your map. Check this Link for more details.
See the output of my result. I created a silver map.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With