ios - 使用 GMS 的 Swift map 样式

标签 ios swift styles gmsmapview

我在当前项目中使用 GMS (Google Maps SDK),它看起来像这样

是否可以将 map 样式设置成这样?并且仍然使用 GMS

最佳答案

您可以在这里按照您想要的方式自定义 map :https://mapstyle.withgoogle.com/

完成自定义后,复制 json 并将其添加到您的项目文件中,比如 style.json

然后将此样式分配给您的 map :

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)")
        } 

关于ios - 使用 GMS 的 Swift map 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39311648/

相关文章:

ios - UILocalNotification - repeatInterval 重置(不重复)

ios - 拉伸(stretch) UIButton 的背景图像

ios - 如何为包含 JSON 数组的 API 端点创建 Siesta 转换器?

css - Angular 2 绑定(bind)所有样式

wolfram-mathematica - listPlot 的多个指令

android - 在自定义 View 中提供默认样式(属性)

objective-c - 对受 OAuth 保护的 URL 进行 GET 调用

ios - MITM 攻击报告已弃用的 NSURLConnectionDelegate

ios - 在核心数据中有效地获取一对多关系中的最新记录

swift - 推/退时隐藏/显示标签栏。 swift