一种或多种地图样式无法加载 - iOS Google Maps SDK
One or more of the map styles failed to load - iOS Google Maps SDK
我已经能够使用默认样式正常运行 G Maps iOS SDK。但我不是所有显示的 Buisness 标签的忠实粉丝所以我决定使用 Map Styler 删除一些
标签和银色外观一起去。我已将 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 文件并删除顶部的所有混乱(可能是在转换为 .json 时创建的)解决了这个问题,现在样式可以工作了就好了。
我已经能够使用默认样式正常运行 G Maps iOS SDK。但我不是所有显示的 Buisness 标签的忠实粉丝所以我决定使用 Map Styler 删除一些 标签和银色外观一起去。我已将 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 文件并删除顶部的所有混乱(可能是在转换为 .json 时创建的)解决了这个问题,现在样式可以工作了就好了。