一个或多个地图样式无法加载 - iOS Google Maps SDK

问题描述 投票:0回答:1

我已经能够让G地图iOS SDK与默认风格工作正常。但我并不喜欢显示所有的商业标签,所以我决定使用 地图样式器 去除一些Labels,并与银色的外观。我把JSON粘贴到一个TextEdit文件中,并把它命名为style.json。我把JSON所需要的代码添加到ViewController中。当我在iOS设备上构建应用程序时,我在控制台中得到一个错误说:"*一个或多个地图样式。

*一个或多个地图样式加载失败。Error Domain=NSCocoaErrorDomain Code=3840 "No string key for value in object around character 1."。UserInfo={NSDebugDescription=字符1周围对象中的值没有字符串键}。 而银色风格不适用。

ViewController.swift - 风格代码

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

有人知道我做错了什么吗?

style.json placement

ios xcode google-maps styles
1个回答
0
投票

我解决了这个问题,进入Style.json文件,并删除所有的杂乱的顶部(可能是创建时转换为.json),现在的风格(S)工作就好了。

© www.soinside.com 2019 - 2024. All rights reserved.