Ios 想改变谷歌地图的背景吗
我想将背景更改为谷歌地图的白色,但我无法更改它。所以,任何人知道这方面的任何细节,请提供给我。如果可能的话,给我一个提示或代码。否则给我一个适当的建议 您可以这样做:Ios 想改变谷歌地图的背景吗,ios,objective-c,swift,google-maps,Ios,Objective C,Swift,Google Maps,我想将背景更改为谷歌地图的白色,但我无法更改它。所以,任何人知道这方面的任何细节,请提供给我。如果可能的话,给我一个提示或代码。否则给我一个适当的建议 您可以这样做: import UIKit import GoogleMaps let kMapStyle = "[" + " {" + " \"featureType\": \"poi.business\"," + " \"elementType\": \"all\"," + " \"stylers\": [" + "
import UIKit
import GoogleMaps
let kMapStyle = "[" +
" {" +
" \"featureType\": \"poi.business\"," +
" \"elementType\": \"all\"," +
" \"stylers\": [" +
" {" +
" \"visibility\": \"off\"" +
" }" +
" ]" +
" }," +
" {" +
" \"featureType\": \"transit\"," +
" \"elementType\": \"labels.icon\"," +
" \"stylers\": [" +
" {" +
" \"visibility\": \"off\"" +
" }" +
" ]" +
" }" +
"]"
class ViewController: UIViewController {
// Set the status bar style to complement night-mode.
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
override func loadView() {
let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 14.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
do {
// Set the map style by passing a valid JSON string.
mapView.mapStyle = try GMSMapStyle(jsonString: kMapStyle)
} catch {
NSLog("One or more of the map styles failed to load. \(error)")
}
self.view = mapView
}
}
在这里创建您的自定义样式
- 创建您的样式并单击finish
- 获取json格式的文本并将其粘贴到代码中
您可以参考@Dhiraj Kumar answer了解代码中的粘贴位置。请参阅@Anbu.Karthik:谢谢。你的评论对我帮助很大。